public void SearchTest() { // Arrange var inModel = new JobseekerModel { DateOfBirth = DateTime.Now, GivenName = "GLENN", Surname = "SUFONG", Gender = "M" }; var request = MappingEngine.Map <RegistrationSearchRequest>(inModel); var searchResultItem = new RegistrationSearchResultItem { JobSeekerId = 3187026003, CRN = "205882473X", Surname = "SUFONG", GivenName = "GLENN", Gender = "M", DateOfBirth = DateTime.Now }; var response = new RegistrationSearchResponse { RegistrationSearchResultItem = (new List <RegistrationSearchResultItem> { searchResultItem }).ToArray() }; var outModel = MappingEngine.Map <JobseekerModel>(response); _mockMappingEngine.Setup(m => m.Map <RegistrationSearchRequest>(inModel)).Returns(request); _mockRegWcf.Setup(m => m.Search(request)).Returns(response); _mockMappingEngine.Setup(m => m.Map <JobseekerModel>(response)).Returns(outModel); // Act var result = SystemUnderTest().Search(inModel); //Assert Assert.IsTrue(result.DuplicateJobseekers.Count() > 0); Assert.IsTrue(result.DuplicateJobseekers.ElementAt(0).JobSeekerId == 3187026003); _mockMappingEngine.Verify(m => m.Map <RegistrationSearchRequest>(inModel), Times.Once()); _mockRegWcf.Verify(m => m.Search(request), Times.Once()); _mockMappingEngine.Verify(m => m.Map <JobseekerModel>(response), Times.Once()); }
public void SearchTestWcfThrowsFaultExceptionThrowsServiceValidationException() { //Arrange var exception = new FaultException(new FaultReason("reason"), new FaultCode("code")); var inModel = new JobseekerModel { DateOfBirth = DateTime.Now, GivenName = "GLENN", Surname = "SUFONG", Gender = "M" }; var request = MappingEngine.Map <RegistrationSearchRequest>(inModel); var searchResultItem = new RegistrationSearchResultItem { JobSeekerId = 3187026003, CRN = "205882473X", Surname = "SUFONG", GivenName = "GLENN", Gender = "M", DateOfBirth = DateTime.Now }; var response = new RegistrationSearchResponse { RegistrationSearchResultItem = (new List <RegistrationSearchResultItem> { searchResultItem }).ToArray() }; var outModel = MappingEngine.Map <IEnumerable <JobseekerModel> >(response.RegistrationSearchResultItem); _mockMappingEngine.Setup(m => m.Map <RegistrationSearchRequest>(inModel)).Returns(request); _mockRegWcf.Setup(m => m.Search(request)).Throws(exception); _mockMappingEngine.Setup(m => m.Map <IEnumerable <JobseekerModel> >(response.RegistrationSearchResultItem)).Returns(outModel); //Act SystemUnderTest().Search(inModel); }