| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106 |
- using Diligent.WebAPI.Contracts.DTOs.SelectionProcess;
- using Diligent.WebAPI.Contracts.Exceptions;
-
- namespace Diligent.WebAPI.Tests.Controllers
- {
- public class SelectionProcessesControllerTests
- {
- private ISelectionProcessService _service = Substitute.For<ISelectionProcessService>();
- private readonly SelectionProcessResposneDto _selectionProcess;
- public SelectionProcessesControllerTests()
- {
- _selectionProcess = new SelectionProcessResposneDto
- {
- Id = 1,
- Name = "HR intervju"
- };
- }
-
- [Fact]
- public async Task FinishSelectionProcess_ShouldReturn_True_WhenProcessExists()
- {
- _service.FinishSelectionProcess(Arg.Any<SelectionProcessCreateDto>()).Returns(true);
- SelectionProcessesController controller = new(_service);
-
- var result = await controller.FinishSelectionProcess(new SelectionProcessCreateDto());
-
- (result as OkObjectResult).StatusCode.Should().Be(200);
- }
-
- [Fact]
- public async Task FinishSelectionProcess_ShouldThrowEntityNotFooundException_WhenProcessDoesnotExist()
- {
- _service.When(x => x.FinishSelectionProcess(Arg.Any<SelectionProcessCreateDto>())).Do(x => { throw new EntityNotFoundException(); });
- SelectionProcessesController controller = new(_service);
-
- await Assert.ThrowsAsync<EntityNotFoundException>(() => controller.FinishSelectionProcess(new SelectionProcessCreateDto()));
- }
-
- [Fact]
- public async Task FinishSelectionProcess_ShouldThrowEntityNotFooundException_WhenProcessWasInLastLevel()
- {
- _service.When(x => x.FinishSelectionProcess(Arg.Any<SelectionProcessCreateDto>())).Do(x => { throw new EntityNotFoundException(); });
- SelectionProcessesController controller = new(_service);
-
- await Assert.ThrowsAsync<EntityNotFoundException>(() => controller.FinishSelectionProcess(new SelectionProcessCreateDto()));
- }
-
- [Fact]
- public async Task UpdateStatus_ShouldReturn_200OK()
- {
- _service.StatusUpdate(Arg.Any<StatusChangeDTO>());
- SelectionProcessesController controller = new(_service);
-
- var result = await controller.UpdateStatus(new StatusChangeDTO());
-
- (result as OkObjectResult).StatusCode.Should().Be(200);
- }
-
- [Fact]
- public async Task UpdateStatus_ShouldThrowEntityNotFooundException_WhenProcessDoesnotExist()
- {
- _service.When(x => x.StatusUpdate(Arg.Any<StatusChangeDTO>())).Do(x => { throw new EntityNotFoundException(); });
- SelectionProcessesController controller = new(_service);
-
- await Assert.ThrowsAsync<EntityNotFoundException>(() => controller.UpdateStatus(new StatusChangeDTO()));
- }
-
- [Fact]
- public async Task UpdateStatus_ShouldThrowEntityNotFooundException_WhenUserDoesNotExist()
- {
- _service.When(x => x.StatusUpdate(Arg.Any<StatusChangeDTO>())).Do(x => { throw new EntityNotFoundException(); });
- SelectionProcessesController controller = new(_service);
-
- await Assert.ThrowsAsync<EntityNotFoundException>(() => controller.UpdateStatus(new StatusChangeDTO()));
- }
-
- [Fact]
- public async Task UpdateInterviewer_ShouldReturn_200OK()
- {
- _service.InterviewerUpdate(Arg.Any<InterviewerUpdateDTO>());
- SelectionProcessesController controller = new(_service);
-
- var result = await controller.UpdateInterviewer(new InterviewerUpdateDTO());
-
- (result as OkObjectResult).StatusCode.Should().Be(200);
- }
-
- [Fact]
- public async Task UpdateInterviewer_ShouldThrowEntityNotFooundException_WhenProcessDoesnotExist()
- {
- _service.When(x => x.InterviewerUpdate(Arg.Any<InterviewerUpdateDTO>())).Do(x => { throw new EntityNotFoundException(); });
- SelectionProcessesController controller = new(_service);
-
- await Assert.ThrowsAsync<EntityNotFoundException>(() => controller.UpdateInterviewer(new InterviewerUpdateDTO()));
- }
-
- [Fact]
- public async Task UpdateInterviewer_ShouldThrowEntityNotFooundException_WhenUserDoesNotExist()
- {
- _service.When(x => x.InterviewerUpdate(Arg.Any<InterviewerUpdateDTO>())).Do(x => { throw new EntityNotFoundException(); });
- SelectionProcessesController controller = new(_service);
-
- await Assert.ThrowsAsync<EntityNotFoundException>(() => controller.UpdateInterviewer(new InterviewerUpdateDTO()));
- }
- }
- }
|