| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- 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()));
- }
- }
- }
|