public async Task ControllerDeleteApplicant_DeleteByID()
        {
            var applicant = new Applicant {
                Name = "Ali_1", FamilyName = "Hosseini", Address = "Address test", Age = 35, CountryOfOrigin = "Aruba", EMailAddress = "*****@*****.**"
            };
            await _controller.PostApplicant(applicant);

            //Delete
            var deleteResult = await _controller.DeleteApplicant(applicant.ID);

            var boolResult = Get(deleteResult);

            Assert.True(boolResult);
        }
コード例 #2
0
        public async Task GivenAnExistingApplicantId_DeleteApplicant_RemovesApplicant()
        {
            var applicantToBeReturned    = fixture.Create <Applicant>();
            var applicantDtoToBeReturned = fixture.Create <ApplicantDto>();

            applicantServiceMock.Setup(mock => mock.GetApplicant(It.Is <int>(id => id == 1)))
            .ReturnsAsync(applicantToBeReturned);

            applicantServiceMock.Setup(mock => mock.DeleteApplicant(It.Is <int>(id => id == 1)))
            .ReturnsAsync(Result.Success);

            mapperMock.Setup(mock => mock.Map <ApplicantDto>(It.IsAny <Applicant>()))
            .Returns(applicantDtoToBeReturned);

            sut = new ApplicantsController(loggerMock.Object, mapperMock.Object, applicantServiceMock.Object);


            var result = await sut.DeleteApplicant(1);

            var actionResult      = Assert.IsAssignableFrom <ActionResult>(result);
            var applicantReturned = Assert.IsType <NoContentResult>(actionResult);
        }