public void Name_should_map_to_SSG_Name_correctly() { var name = new NameActual() { FirstName = "FirstName", LastName = "LastName", MiddleName = "MiddleName", Type = "Legal Name", EffectiveDate = new DateTimeOffset(new DateTime(2001, 1, 1)), EndDate = new DateTimeOffset(new DateTime(2002, 2, 1)), Description = "test name" }; SSG_Aliase ssg_name = _mapper.Map <SSG_Aliase>(name); Assert.AreEqual("FirstName", ssg_name.FirstName); Assert.AreEqual("LastName", ssg_name.LastName); Assert.AreEqual("MiddleName", ssg_name.MiddleName); Assert.AreEqual("FirstName MiddleName LastName", ssg_name.FullName); Assert.AreEqual(PersonNameCategory.LegalName.Value, ssg_name.Type); Assert.AreEqual("test name", ssg_name.Comments); Assert.AreEqual(1, ssg_name.StatusCode); Assert.AreEqual(0, ssg_name.StateCode); Assert.AreEqual(new DateTime(2001, 1, 1), ssg_name.EffectiveDate); Assert.AreEqual(new DateTime(2002, 2, 1), ssg_name.EndDate); Assert.AreEqual("Effective Date", ssg_name.EffectiveDateLabel); Assert.AreEqual("End Date", ssg_name.EndDateLabel); }
private async Task <bool> UploadNames( ) { if (_foundPerson.Names == null) { return(true); } try { _logger.LogDebug($"Attempting to create found name records for SearchRequest[{_searchRequest.SearchRequestId}]"); foreach (var name in _foundPerson.Names) { AliasEntity n = _mapper.Map <AliasEntity>(name); n.SearchRequest = _searchRequest; n.InformationSource = _providerDynamicsID; n.Person = _returnedPerson; SSG_Aliase alias = await _searchRequestService.CreateName(n, _cancellationToken); await CreateResultTransaction(alias); } return(true); } catch (Exception ex) { LogException(ex); return(false); } }
public async Task with_correct_searchRequestid_upload_name_should_success() { var name = new SSG_Aliase() { FirstName = "firstName", LastName = "lastName", MiddleName = "middleName", Comments = "testComments", Type = PersonNameCategory.LegalName.Value, Notes = "notes", ThirdGivenName = "thirdName", SupplierTypeCode = "legal", Date1 = new DateTime(2001, 1, 1), Date1Label = "date1lable", SearchRequest = new SSG_SearchRequest() { SearchRequestId = testId }, Person = new SSG_Person() { PersonId = testPersonId } }; var result = await _sut.CreateName(name, CancellationToken.None); Assert.AreEqual("firstName", result.FirstName); }
private async Task <bool> UploadNames(SSG_SearchRequest request, PersonSearchCompleted personCompletedEvent, CancellationToken concellationToken) { if (personCompletedEvent.MatchedPerson.Names == null) { return(true); } foreach (var name in personCompletedEvent.MatchedPerson.Names) { SSG_Aliase n = _mapper.Map <SSG_Aliase>(name); n.SearchRequest = request; n.InformationSource = personCompletedEvent.ProviderProfile.DynamicsID(); await _searchRequestService.CreateName(n, concellationToken); } return(true); }
public void SSG_Aliase_should_map_to_Person_Name_correctly() { var alias = new SSG_Aliase { FirstName = "aliasFirstName", Date1 = new DateTime(2000, 1, 1), Date1Label = "label", ResponseComments = "aliasComments", DateOfBirth = new DateTime(2004, 1, 1) }; Name name = _mapper.Map <Name>(alias); Assert.AreEqual("aliasFirstName", name.FirstName); Assert.AreEqual(new DateTimeOffset(new DateTime(2004, 1, 1)), name.DateOfBirth); }
public async Task with_correct_searchRequestid_upload_name_should_success() { var name = new SSG_Aliase() { FirstName = "firstName", LastName = "lastName", MiddleName = "middleName", FullName = "firstName middleName lastName", Comments = "testComments", Type = PersonNameCategory.MaidenName.Value, SearchRequest = new SSG_SearchRequest() { SearchRequestId = testId } }; var result = await _sut.CreateName(name, CancellationToken.None); Assert.AreEqual("firstName middleName lastName", result.FullName); }
public void Name_should_map_to_SSG_Name_correctly() { var name = new Name() { FirstName = "FirstName", LastName = "LastName", MiddleName = "MiddleName", OtherName = "OtherName", Type = "Former", Description = "test name", Notes = "notes", ReferenceDates = new List <ReferenceDate>() { new ReferenceDate() { Index = 0, Key = "startDate", Value = new DateTime(2012, 1, 1) }, new ReferenceDate() { Index = 1, Key = "endDate", Value = new DateTime(2014, 1, 1) }, } }; SSG_Aliase ssg_name = _mapper.Map <SSG_Aliase>(name); Assert.AreEqual("FirstName", ssg_name.FirstName); Assert.AreEqual("LastName", ssg_name.LastName); Assert.AreEqual("MiddleName", ssg_name.MiddleName); Assert.AreEqual("OtherName", ssg_name.ThirdGivenName); Assert.AreEqual(PersonNameCategory.Other.Value, ssg_name.Type); Assert.AreEqual("test name", ssg_name.Comments); Assert.AreEqual("notes", ssg_name.Notes); Assert.AreEqual("Former", ssg_name.SupplierTypeCode); Assert.AreEqual(1, ssg_name.StatusCode); Assert.AreEqual(0, ssg_name.StateCode); Assert.AreEqual(new DateTime(2012, 1, 1), ssg_name.Date1); Assert.AreEqual(new DateTime(2014, 1, 1), ssg_name.Date2); Assert.AreEqual("startDate", ssg_name.Date1Label); Assert.AreEqual("endDate", ssg_name.Date2Label); }
private async Task <bool> UploadNames(Person person, SSG_SearchRequest request, SSG_Person ssg_person, int?providerDynamicsID, CancellationToken concellationToken) { if (person.Names == null) { return(true); } try { foreach (var name in person.Names) { SSG_Aliase n = _mapper.Map <SSG_Aliase>(name); n.SearchRequest = request; n.InformationSource = providerDynamicsID; n.Person = ssg_person; await _searchRequestService.CreateName(n, concellationToken); } return(true); } catch (Exception ex) { _logger.LogError(ex.Message); return(false); } }
public async Task <SSG_Aliase> CreateName(SSG_Aliase name, CancellationToken cancellationToken) { return(await this._oDataClient.For <SSG_Aliase>().Set(name).InsertEntryAsync(cancellationToken)); }
public void Init() { _testGuid = Guid.NewGuid(); _testFileId = "testFileId"; _exceptionGuid = Guid.NewGuid(); _loggerMock = new Mock <ILogger <PersonSearchController> >(); _searchApiRequestServiceMock = new Mock <ISearchApiRequestService>(); _searchResultServiceMock = new Mock <ISearchResultService>(); _mapper = new Mock <IMapper>(); var validRequestId = Guid.NewGuid(); var invalidRequestId = Guid.NewGuid(); _fakeSearchApiEvent = new SSG_SearchApiEvent { }; _fakePersoneIdentifier = new SSG_Identifier { SearchRequest = new SSG_SearchRequest { SearchRequestId = validRequestId } }; _fakePersonAddress = new SSG_Address { SearchRequest = new SSG_SearchRequest { SearchRequestId = validRequestId } }; _fakePersonPhoneNumber = new SSG_PhoneNumber { SearchRequest = new SSG_SearchRequest { SearchRequestId = validRequestId } }; _fakeName = new SSG_Aliase { SearchRequest = new SSG_SearchRequest { SearchRequestId = validRequestId } }; _fakePerson = new SSG_Person { SearchRequest = new SSG_SearchRequest { SearchRequestId = validRequestId } }; _fakePersonAcceptedEvent = new PersonSearchAccepted() { SearchRequestId = Guid.NewGuid(), FileId = _testFileId, TimeStamp = DateTime.Now, ProviderProfile = new ProviderProfile() { Name = "TEST PROVIDER" } }; _fakePersonCompletedEvent = new PersonSearchCompleted() { SearchRequestId = Guid.NewGuid(), FileId = _testFileId, TimeStamp = DateTime.Now, ProviderProfile = new ProviderProfile() { Name = "TEST PROVIDER" }, MatchedPersons = new List <Person>() { new Person() { DateOfBirth = DateTime.Now, FirstName = "TEST1", LastName = "TEST2", Identifiers = new List <PersonalIdentifier>() { }, Addresses = new List <Address>() { }, Phones = new List <Phone>() { }, Names = new List <Name>() { } } } }; _fakePersonFailedEvent = new PersonSearchFailed() { SearchRequestId = Guid.NewGuid(), FileId = _testFileId, TimeStamp = DateTime.Now, ProviderProfile = new ProviderProfile() { Name = "TEST PROVIDER" }, Cause = "Unable to proceed" }; _fakePersonRejectEvent = new PersonSearchRejected() { SearchRequestId = Guid.NewGuid(), FileId = _testFileId, TimeStamp = DateTime.Now, ProviderProfile = new ProviderProfile() { Name = "TEST PROVIDER" }, Reasons = new List <ValidationResult> { } }; _fakePersonFinalizedEvent = new PersonSearchFinalized() { SearchRequestId = Guid.NewGuid(), FileId = _testFileId, TimeStamp = DateTime.Now, Message = "test message" }; _mapper.Setup(m => m.Map <SSG_SearchApiEvent>(It.IsAny <PersonSearchAccepted>())) .Returns(_fakeSearchApiEvent); _mapper.Setup(m => m.Map <SSG_SearchApiEvent>(It.IsAny <PersonSearchRejected>())) .Returns(_fakeSearchApiEvent); _mapper.Setup(m => m.Map <SSG_SearchApiEvent>(It.IsAny <PersonSearchFailed>())) .Returns(_fakeSearchApiEvent); _mapper.Setup(m => m.Map <SSG_SearchApiEvent>(It.IsAny <PersonSearchCompleted>())) .Returns(_fakeSearchApiEvent); _mapper.Setup(m => m.Map <SSG_Identifier>(It.IsAny <PersonalIdentifier>())) .Returns(_fakePersoneIdentifier); _mapper.Setup(m => m.Map <SSG_PhoneNumber>(It.IsAny <Phone>())) .Returns(_fakePersonPhoneNumber); _mapper.Setup(m => m.Map <SSG_Address>(It.IsAny <Address>())) .Returns(_fakePersonAddress); _mapper.Setup(m => m.Map <SSG_Aliase>(It.IsAny <Name>())) .Returns(_fakeName); _mapper.Setup(m => m.Map <SSG_Person>(It.IsAny <Person>())) .Returns(_fakePerson); _searchApiRequestServiceMock.Setup(x => x.GetLinkedSearchRequestIdAsync(It.Is <Guid>(x => x == _testGuid), It.IsAny <CancellationToken>())) .Returns(Task.FromResult <Guid>(_testGuid)); _searchApiRequestServiceMock.Setup(x => x.GetLinkedSearchRequestIdAsync(It.Is <Guid>(x => x == _exceptionGuid), It.IsAny <CancellationToken>())) .Returns(Task.FromResult <Guid>(invalidRequestId)); _searchApiRequestServiceMock.Setup(x => x.MarkComplete(It.Is <Guid>(x => x == _testGuid), It.IsAny <CancellationToken>())) .Returns(Task.FromResult <SSG_SearchApiRequest>(new SSG_SearchApiRequest() { SearchApiRequestId = _testGuid, Name = "Random Event" })); _searchResultServiceMock.Setup(x => x.ProcessPersonFound(It.Is <Person>(x => x.FirstName == "TEST1"), It.IsAny <ProviderProfile>(), It.IsAny <SSG_SearchRequest>(), It.IsAny <CancellationToken>())) .Returns(Task.FromResult <bool>(true)); _searchApiRequestServiceMock.Setup(x => x.AddEventAsync(It.Is <Guid>(x => x == _testGuid), It.IsAny <SSG_SearchApiEvent>(), It.IsAny <CancellationToken>())) .Returns(Task.FromResult <SSG_SearchApiEvent>(new SSG_SearchApiEvent() { Id = _testGuid, Name = "Random Event" })); _searchApiRequestServiceMock.Setup(x => x.AddEventAsync(It.Is <Guid>(x => x == _exceptionGuid), It.IsAny <SSG_SearchApiEvent>(), It.IsAny <CancellationToken>())) .Throws(new Exception("random exception")); _sut = new PersonSearchController(_searchResultServiceMock.Object, _searchApiRequestServiceMock.Object, _loggerMock.Object, _mapper.Object); }
public void Init() { _loggerMock = new Mock <ILogger <SearchResultService> >(); _searchRequestServiceMock = new Mock <ISearchRequestService>(); _mapper = new Mock <IMapper>(); var validRequestId = Guid.NewGuid(); var invalidRequestId = Guid.NewGuid(); var validVehicleId = Guid.NewGuid(); var validOtherAssetId = Guid.NewGuid(); _fakePersoneIdentifier = new SSG_Identifier { SearchRequest = new SSG_SearchRequest { SearchRequestId = validRequestId } }; _fakePersonAddress = new SSG_Address { SearchRequest = new SSG_SearchRequest { SearchRequestId = validRequestId } }; _fakeEmployment = new EmploymentEntity { SearchRequest = new SSG_SearchRequest { SearchRequestId = validRequestId } }; _fakeEmploymentContact = new SSG_EmploymentContact { PhoneNumber = "11111111" }; _fakePersonPhoneNumber = new SSG_PhoneNumber { SearchRequest = new SSG_SearchRequest { SearchRequestId = validRequestId } }; _fakeRelatedPerson = new SSG_Identity { SearchRequest = new SSG_SearchRequest { SearchRequestId = validRequestId } }; _fakeName = new SSG_Aliase { SearchRequest = new SSG_SearchRequest { SearchRequestId = validRequestId } }; _ssg_fakePerson = new PersonEntity { }; _searchRequest = new SSG_SearchRequest { SearchRequestId = validRequestId }; _fakeBankInfo = new SSG_Asset_BankingInformation { BankName = "bank" }; _fakeVehicleEntity = new VehicleEntity { SearchRequest = _searchRequest, PlateNumber = "AAA.BBB" }; _fakeAssetOwner = new SSG_AssetOwner() { OrganizationName = "Ford Inc." }; _fakeOtherAsset = new AssetOtherEntity() { SearchRequest = _searchRequest, TypeDescription = "type description" }; _fakePerson = new Person() { DateOfBirth = DateTime.Now, FirstName = "TEST1", LastName = "TEST2", Identifiers = new List <PersonalIdentifier>() { new PersonalIdentifier() { Value = "test", IssuedBy = "test", Type = PersonalIdentifierType.BCDriverLicense } }, Addresses = new List <Address>() { new Address() { AddressLine1 = "AddressLine1", AddressLine2 = "AddressLine2", AddressLine3 = "AddressLine3", StateProvince = "Manitoba", City = "testCity", Type = "residence", CountryRegion = "canada", ZipPostalCode = "p3p3p3", ReferenceDates = new List <ReferenceDate>() { new ReferenceDate() { Index = 0, Key = "Start Date", Value = new DateTime(2019, 9, 1) }, new ReferenceDate() { Index = 1, Key = "End Date", Value = new DateTime(2020, 9, 1) } }, Description = "description" } }, Phones = new List <Phone>() { new Phone() { PhoneNumber = "4005678900" } }, Names = new List <Name>() { new Name() { FirstName = "firstName" } }, RelatedPersons = new List <RelatedPerson>() { new RelatedPerson() { FirstName = "firstName" } }, Employments = new List <Employment>() { new Employment() { Occupation = "Occupation", Employer = new Employer() { Phones = new List <Phone>() { new Phone() { PhoneNumber = "1111111", Type = "Phone" } } } } }, BankInfos = new List <BankInfo>() { new BankInfo() { BankName = "BankName", } }, Vehicles = new List <Vehicle>() { new Vehicle() { }, new Vehicle() { Owners = new List <AssetOwner>() { new AssetOwner() { } } } }, OtherAssets = new List <OtherAsset>() { new OtherAsset() { Owners = new List <AssetOwner>() { new AssetOwner() { } } } } }; _providerProfile = new ProviderProfile() { Name = "Other" }; _fakeToken = new CancellationToken(); _mapper.Setup(m => m.Map <SSG_Identifier>(It.IsAny <PersonalIdentifier>())) .Returns(_fakePersoneIdentifier); _mapper.Setup(m => m.Map <SSG_PhoneNumber>(It.IsAny <Phone>())) .Returns(_fakePersonPhoneNumber); _mapper.Setup(m => m.Map <SSG_Address>(It.IsAny <Address>())) .Returns(_fakePersonAddress); _mapper.Setup(m => m.Map <SSG_Aliase>(It.IsAny <Name>())) .Returns(_fakeName); _mapper.Setup(m => m.Map <PersonEntity>(It.IsAny <Person>())) .Returns(_ssg_fakePerson); _mapper.Setup(m => m.Map <EmploymentEntity>(It.IsAny <Employment>())) .Returns(_fakeEmployment); _mapper.Setup(m => m.Map <SSG_EmploymentContact>(It.IsAny <Phone>())) .Returns(_fakeEmploymentContact); _mapper.Setup(m => m.Map <SSG_Identity>(It.IsAny <RelatedPerson>())) .Returns(_fakeRelatedPerson); _mapper.Setup(m => m.Map <SSG_Asset_BankingInformation>(It.IsAny <BankInfo>())) .Returns(_fakeBankInfo); _mapper.Setup(m => m.Map <VehicleEntity>(It.IsAny <Vehicle>())) .Returns(_fakeVehicleEntity); _mapper.Setup(m => m.Map <SSG_AssetOwner>(It.IsAny <AssetOwner>())) .Returns(_fakeAssetOwner); _mapper.Setup(m => m.Map <AssetOtherEntity>(It.IsAny <OtherAsset>())) .Returns(_fakeOtherAsset); _searchRequestServiceMock.Setup(x => x.CreateIdentifier(It.Is <SSG_Identifier>(x => x.SearchRequest.SearchRequestId == invalidRequestId), It.IsAny <CancellationToken>())) .Throws(new Exception("random exception")); _searchRequestServiceMock.Setup(x => x.CreateAddress(It.Is <SSG_Address>(x => x.SearchRequest.SearchRequestId == validRequestId), It.IsAny <CancellationToken>())) .Returns(Task.FromResult <SSG_Address>(new SSG_Address() { AddressLine1 = "test full line" })); _searchRequestServiceMock.Setup(x => x.CreatePhoneNumber(It.Is <SSG_PhoneNumber>(x => x.SearchRequest.SearchRequestId == validRequestId), It.IsAny <CancellationToken>())) .Returns(Task.FromResult <SSG_PhoneNumber>(new SSG_PhoneNumber() { TelePhoneNumber = "4007678231" })); _searchRequestServiceMock.Setup(x => x.CreateName(It.Is <SSG_Aliase>(x => x.SearchRequest.SearchRequestId == validRequestId), It.IsAny <CancellationToken>())) .Returns(Task.FromResult <SSG_Aliase>(new SSG_Aliase() { FirstName = "firstName" })); _searchRequestServiceMock.Setup(x => x.SavePerson(It.Is <PersonEntity>(x => x.SearchRequest.SearchRequestId == validRequestId), It.IsAny <CancellationToken>())) .Returns(Task.FromResult <SSG_Person>(new SSG_Person() { FirstName = "First" })); _searchRequestServiceMock.Setup(x => x.CreateEmployment(It.Is <EmploymentEntity>(x => x.SearchRequest.SearchRequestId == validRequestId), It.IsAny <CancellationToken>())) .Returns(Task.FromResult <SSG_Employment>(new SSG_Employment() { EmploymentId = Guid.NewGuid(), Occupation = "Occupation" })); _searchRequestServiceMock.Setup(x => x.CreateEmploymentContact(It.IsAny <SSG_EmploymentContact>(), It.IsAny <CancellationToken>())) .Returns(Task.FromResult <SSG_EmploymentContact>(new SSG_EmploymentContact() { PhoneNumber = "4007678231" })); _searchRequestServiceMock.Setup(x => x.CreateRelatedPerson(It.Is <SSG_Identity>(x => x.SearchRequest.SearchRequestId == validRequestId), It.IsAny <CancellationToken>())) .Returns(Task.FromResult <SSG_Identity>(new SSG_Identity() { FirstName = "firstName" })); _searchRequestServiceMock.Setup(x => x.CreateBankInfo(It.Is <SSG_Asset_BankingInformation>(x => x.SearchRequest.SearchRequestId == validRequestId), It.IsAny <CancellationToken>())) .Returns(Task.FromResult <SSG_Asset_BankingInformation>(new SSG_Asset_BankingInformation() { BankName = "bankName" })); _searchRequestServiceMock.Setup(x => x.CreateVehicle(It.Is <VehicleEntity>(x => x.SearchRequest.SearchRequestId == validRequestId), It.IsAny <CancellationToken>())) .Returns(Task.FromResult <SSG_Asset_Vehicle>(new SSG_Asset_Vehicle() { VehicleId = validVehicleId })); _searchRequestServiceMock.Setup(x => x.CreateAssetOwner(It.Is <SSG_AssetOwner>(x => x.Vehicle.VehicleId == validVehicleId), It.IsAny <CancellationToken>())) .Returns(Task.FromResult <SSG_AssetOwner>(new SSG_AssetOwner() { Type = "Owner" })); _searchRequestServiceMock.Setup(x => x.CreateOtherAsset(It.Is <AssetOtherEntity>(x => x.SearchRequest.SearchRequestId == validRequestId), It.IsAny <CancellationToken>())) .Returns(Task.FromResult <SSG_Asset_Other>(new SSG_Asset_Other() { AssetOtherId = validOtherAssetId })); _sut = new SearchResultService(_searchRequestServiceMock.Object, _loggerMock.Object, _mapper.Object); }
public void Init() { _testGuid = Guid.NewGuid(); _exceptionGuid = Guid.NewGuid(); _loggerMock = new Mock <ILogger <PersonSearchController> >(); _searchApiRequestServiceMock = new Mock <ISearchApiRequestService>(); _searchRequestServiceMock = new Mock <ISearchRequestService>(); _mapper = new Mock <IMapper>(); var validRequestId = Guid.NewGuid(); var invalidRequestId = Guid.NewGuid(); fakeSearchApiEvent = new SSG_SearchApiEvent { }; _fakePersoneIdentifier = new SSG_Identifier { SSG_SearchRequest = new SSG_SearchRequest { SearchRequestId = validRequestId } }; _fakePersonAddress = new SSG_Address { SearchRequest = new SSG_SearchRequest { SearchRequestId = validRequestId } }; _fakePersonPhoneNumber = new SSG_PhoneNumber { SearchRequest = new SSG_SearchRequest { SearchRequestId = validRequestId } }; _fakeName = new SSG_Aliase { SearchRequest = new SSG_SearchRequest { SearchRequestId = validRequestId } }; fakePersonAcceptedEvent = new PersonSearchAccepted() { SearchRequestId = Guid.NewGuid(), TimeStamp = DateTime.Now, ProviderProfile = new ProviderProfile() { Name = "TEST PROVIDER" } }; _fakePersonCompletedEvent = new PersonSearchCompleted() { SearchRequestId = Guid.NewGuid(), TimeStamp = DateTime.Now, ProviderProfile = new ProviderProfile() { Name = "TEST PROVIDER" }, MatchedPerson = new Person() { DateOfBirth = DateTime.Now, FirstName = "TEST1", LastName = "TEST2", Identifiers = new List <PersonalIdentifierActual>() { new PersonalIdentifierActual() { Value = "test", IssuedBy = "test", Type = PersonalIdentifierType.DriverLicense } }, Addresses = new List <AddressActual>() { new AddressActual() { AddressLine1 = "AddressLine1", AddressLine2 = "AddressLine2", AddressLine3 = "AddressLine3", StateProvince = "Manitoba", City = "testCity", Type = "residence", CountryRegion = "canada", ZipPostalCode = "p3p3p3", SuppliedBy = "Employer" } }, PhoneNumbers = new List <PhoneNumberActual>() { new PhoneNumberActual() { PhoneNumber1 = "4005678900" } }, Names = new List <NameActual>() { new NameActual() { FirstName = "firstName" } } } }; fakePersonFailedEvent = new PersonSearchFailed() { SearchRequestId = Guid.NewGuid(), TimeStamp = DateTime.Now, ProviderProfile = new ProviderProfile() { Name = "TEST PROVIDER" }, Cause = "Unable to proceed" }; fakePersonRejectEvent = new PersonSearchRejected() { SearchRequestId = Guid.NewGuid(), TimeStamp = DateTime.Now, ProviderProfile = new ProviderProfile() { Name = "TEST PROVIDER" }, Reasons = new List <ValidationResult> { } }; _mapper.Setup(m => m.Map <SSG_SearchApiEvent>(It.IsAny <PersonSearchAccepted>())) .Returns(fakeSearchApiEvent); _mapper.Setup(m => m.Map <SSG_SearchApiEvent>(It.IsAny <PersonSearchRejected>())) .Returns(fakeSearchApiEvent); _mapper.Setup(m => m.Map <SSG_SearchApiEvent>(It.IsAny <PersonSearchFailed>())) .Returns(fakeSearchApiEvent); _mapper.Setup(m => m.Map <SSG_SearchApiEvent>(It.IsAny <PersonSearchCompleted>())) .Returns(fakeSearchApiEvent); _mapper.Setup(m => m.Map <SSG_Identifier>(It.IsAny <PersonalIdentifier>())) .Returns(_fakePersoneIdentifier); _mapper.Setup(m => m.Map <SSG_PhoneNumber>(It.IsAny <PhoneNumber>())) .Returns(_fakePersonPhoneNumber); _mapper.Setup(m => m.Map <SSG_Address>(It.IsAny <Web.Address>())) .Returns(_fakePersonAddress); _mapper.Setup(m => m.Map <SSG_Aliase>(It.IsAny <Name>())) .Returns(_fakeName); _searchApiRequestServiceMock.Setup(x => x.GetLinkedSearchRequestIdAsync(It.Is <Guid>(x => x == _testGuid), It.IsAny <CancellationToken>())) .Returns(Task.FromResult <Guid>(_testGuid)); _searchApiRequestServiceMock.Setup(x => x.GetLinkedSearchRequestIdAsync(It.Is <Guid>(x => x == _exceptionGuid), It.IsAny <CancellationToken>())) .Returns(Task.FromResult <Guid>(invalidRequestId)); _searchRequestServiceMock.Setup(x => x.CreateIdentifier(It.Is <SSG_Identifier>(x => x.SSG_SearchRequest.SearchRequestId == validRequestId), It.IsAny <CancellationToken>())) .Returns(Task.FromResult <SSG_Identifier>(new SSG_Identifier() { Identification = "test identification" })); _searchRequestServiceMock.Setup(x => x.CreateIdentifier(It.Is <SSG_Identifier>(x => x.SSG_SearchRequest.SearchRequestId == invalidRequestId), It.IsAny <CancellationToken>())) .Throws(new Exception("random exception")); _searchRequestServiceMock.Setup(x => x.CreateAddress(It.Is <SSG_Address>(x => x.SearchRequest.SearchRequestId == validRequestId), It.IsAny <CancellationToken>())) .Returns(Task.FromResult <SSG_Address>(new SSG_Address() { FullText = "test full line" })); _searchRequestServiceMock.Setup(x => x.CreatePhoneNumber(It.Is <SSG_PhoneNumber>(x => x.SearchRequest.SearchRequestId == validRequestId), It.IsAny <CancellationToken>())) .Returns(Task.FromResult <SSG_PhoneNumber>(new SSG_PhoneNumber() { TelePhoneNumber = "4007678231" })); _searchRequestServiceMock.Setup(x => x.CreateName(It.Is <SSG_Aliase>(x => x.SearchRequest.SearchRequestId == validRequestId), It.IsAny <CancellationToken>())) .Returns(Task.FromResult <SSG_Aliase>(new SSG_Aliase() { FirstName = "firstName" })); _searchApiRequestServiceMock.Setup(x => x.AddEventAsync(It.Is <Guid>(x => x == _testGuid), It.IsAny <SSG_SearchApiEvent>(), It.IsAny <CancellationToken>())) .Returns(Task.FromResult <SSG_SearchApiEvent>(new SSG_SearchApiEvent() { Id = _testGuid, Name = "Random Event" })); _searchApiRequestServiceMock.Setup(x => x.AddEventAsync(It.Is <Guid>(x => x == _exceptionGuid), It.IsAny <SSG_SearchApiEvent>(), It.IsAny <CancellationToken>())) .Throws(new Exception("random exception")); _sut = new PersonSearchController(_searchRequestServiceMock.Object, _searchApiRequestServiceMock.Object, _loggerMock.Object, _mapper.Object); }