private async Task <bool> UploadOtherAssets(Person person, SSG_SearchRequest request, SSG_Person ssg_person, int?providerDynamicsID, CancellationToken concellationToken)
        {
            if (person.OtherAssets == null)
            {
                return(true);
            }
            try
            {
                foreach (OtherAsset asset in person.OtherAssets)
                {
                    AssetOtherEntity other = _mapper.Map <AssetOtherEntity>(asset);
                    other.SearchRequest     = request;
                    other.InformationSource = providerDynamicsID;
                    other.Person            = ssg_person;
                    SSG_Asset_Other ssgOtherAsset = await _searchRequestService.CreateOtherAsset(other, concellationToken);

                    if (asset.Owners != null)
                    {
                        foreach (var owner in asset.Owners)
                        {
                            SSG_AssetOwner assetOwner = _mapper.Map <SSG_AssetOwner>(owner);
                            assetOwner.OtherAsset = ssgOtherAsset;
                            await _searchRequestService.CreateAssetOwner(assetOwner, concellationToken);
                        }
                    }
                }
                return(true);
            }
            catch (Exception ex)
            {
                _logger.LogError(ex.Message);
                return(false);
            }
        }
Exemple #2
0
        public async Task with_correct_searchRequestid_upload_otherasset_should_success()
        {
            var assetOther = new AssetOtherEntity()
            {
                AssetDescription = "asset description",
                Description      = "description",
                TypeDescription  = "asset type description",
                Notes            = "notes",
                Date1            = new DateTime(2001, 1, 1),
                Date1Label       = "date1lable",
                Date2            = new DateTime(2005, 1, 1),
                Date2Label       = "date2lable",
                SearchRequest    = new SSG_SearchRequest()
                {
                    SearchRequestId = testId
                },
                Person = new SSG_Person()
                {
                    PersonId = testPersonId
                }
            };

            var result = await _sut.CreateOtherAsset(assetOther, CancellationToken.None);

            Assert.AreEqual(testAssetOtherId, result.AssetOtherId);
        }
        public async Task <SSG_Asset_Other> CreateOtherAsset(AssetOtherEntity otherAsset, CancellationToken cancellationToken)
        {
            if (otherAsset.Person.IsDuplicated)
            {
                Guid duplicatedOtherAssetId = await _duplicateDetectService.Exists(otherAsset.Person, otherAsset);

                if (duplicatedOtherAssetId != Guid.Empty)
                {
                    return new SSG_Asset_Other()
                           {
                               AssetOtherId = duplicatedOtherAssetId
                           }
                }
                ;
            }
            return(await this._oDataClient.For <SSG_Asset_Other>().Set(otherAsset).InsertEntryAsync(cancellationToken));
        }
        public async Task with_duplicated_person_contains_same_otherAsset_should_return_original_otherAsset_guid()
        {
            _testOtherAssetId = Guid.NewGuid();
            _duplicateServiceMock.Setup(x => x.Exists(It.Is <SSG_Person>(m => m.PersonId == _testId), It.Is <AssetOtherEntity>(m => m.Description == "contain")))
            .Returns(Task.FromResult(_testOtherAssetId));

            var otherAsset = new AssetOtherEntity()
            {
                Description = "contain",
                Person      = new SSG_Person()
                {
                    PersonId     = _testId,
                    IsDuplicated = true
                }
            };
            var result = await _sut.CreateOtherAsset(otherAsset, CancellationToken.None);

            Assert.AreEqual(_testOtherAssetId, result.AssetOtherId);
        }
Exemple #5
0
        public void OtherAsset_should_map_to_AssetOtherEntity_correctly()
        {
            var otherAsset = new OtherAsset()
            {
                TypeDescription      = "TypeDescription",
                ReferenceDescription = "referenceDescription",
                ReferenceValue       = "referenceValue",
                Description          = "description",
                Notes  = "notes",
                Owners = new List <AssetOwner>()
                {
                    new AssetOwner()
                    {
                    }
                },

                ReferenceDates = new List <ReferenceDate>()
                {
                    new ReferenceDate()
                    {
                        Index = 0, Key = "start date", Value = new DateTimeOffset(new DateTime(2012, 1, 1))
                    },
                    new ReferenceDate()
                    {
                        Index = 1, Key = "end date", Value = new DateTimeOffset(new DateTime(2014, 1, 1))
                    }
                }
            };
            AssetOtherEntity assetEntity = _mapper.Map <AssetOtherEntity>(otherAsset);

            Assert.AreEqual("TypeDescription", assetEntity.TypeDescription);
            Assert.AreEqual("description", assetEntity.AssetDescription);
            Assert.AreEqual("referenceDescription referenceValue", assetEntity.Description);
            Assert.AreEqual("notes", assetEntity.Notes);
            Assert.AreEqual(1, assetEntity.StatusCode);
            Assert.AreEqual(0, assetEntity.StateCode);
            Assert.AreEqual(new DateTime(2012, 1, 1), assetEntity.Date1);
            Assert.AreEqual(new DateTime(2014, 1, 1), assetEntity.Date2);
            Assert.AreEqual("start date", assetEntity.Date1Label);
            Assert.AreEqual("end date", assetEntity.Date2Label);
        }
        public async Task person_does_not_contain_same_otherasset_Exists_should_return_empty_guid()
        {
            DuplicateDetectionService._configs = null;
            Guid       existedOtherAssetID = Guid.NewGuid();
            SSG_Person person = new SSG_Person()
            {
                SSG_Asset_Others = new List <SSG_Asset_Other>()
                {
                    new SSG_Asset_Other()
                    {
                        TypeDescription = "otherasset111", AssetOtherId = existedOtherAssetID
                    }
                }.ToArray()
            };
            AssetOtherEntity entity = new AssetOtherEntity()
            {
                TypeDescription = "otherasset", Notes = "notes"
            };
            Guid guid = await _sut.Exists(person, entity);

            Assert.AreEqual(Guid.Empty, guid);
        }
Exemple #7
0
        private async Task <bool> UploadOtherAssets()
        {
            if (_foundPerson.OtherAssets == null)
            {
                return(true);
            }
            try
            {
                _logger.LogDebug($"Attempting to create other assets records for SearchRequest[{_searchRequest.SearchRequestId}]");

                foreach (OtherAsset asset in _foundPerson.OtherAssets)
                {
                    AssetOtherEntity other = _mapper.Map <AssetOtherEntity>(asset);
                    other.SearchRequest     = _searchRequest;
                    other.InformationSource = _providerDynamicsID;
                    other.Person            = _returnedPerson;
                    SSG_Asset_Other ssgOtherAsset = await _searchRequestService.CreateOtherAsset(other, _cancellationToken);

                    if (asset.Owners != null)
                    {
                        foreach (var owner in asset.Owners)
                        {
                            AssetOwnerEntity assetOwner = _mapper.Map <AssetOwnerEntity>(owner);
                            assetOwner.OtherAsset = ssgOtherAsset;
                            await _searchRequestService.CreateAssetOwner(assetOwner, _cancellationToken);
                        }
                    }

                    await CreateResultTransaction(ssgOtherAsset);
                }
                return(true);
            }
            catch (Exception ex)
            {
                LogException(ex);
                return(false);
            }
        }
Exemple #8
0
        public void Init()
        {
            _loggerMock = new Mock <ILogger <SearchResultService> >();
            _searchRequestServiceMock = new Mock <ISearchRequestService>();
            _mapper = new Mock <IMapper>();
            var validRequestId = Guid.NewGuid();

            var validVehicleId         = Guid.NewGuid();
            var validOtherAssetId      = Guid.NewGuid();
            var validBankInformationId = Guid.NewGuid();
            var validEmploymentId      = Guid.NewGuid();

            _fakePersoneIdentifier = new IdentifierEntity
            {
                Identification = "1234567",
                SearchRequest  = new SSG_SearchRequest
                {
                    SearchRequestId = validRequestId
                }
            };

            _fakeSourceIdentifier = new SSG_Identifier
            {
                SearchRequest = new SSG_SearchRequest
                {
                    SearchRequestId = validRequestId
                }
            };

            _fakePersonAddress = new AddressEntity
            {
                SearchRequest = new SSG_SearchRequest
                {
                    SearchRequestId = validRequestId
                },
                AddressLine1 = "addressLine1"
            };
            _fakeEmployment = new EmploymentEntity
            {
                SearchRequest = new SSG_SearchRequest
                {
                    SearchRequestId = validRequestId
                }
            };

            _fakeEmploymentContact = new EmploymentContactEntity
            {
                PhoneNumber = "11111111"
            };

            _fakePersonPhoneNumber = new PhoneNumberEntity
            {
                SearchRequest = new SSG_SearchRequest
                {
                    SearchRequestId = validRequestId
                }
            };

            _fakeRelatedPerson = new RelatedPersonEntity
            {
                SearchRequest = new SSG_SearchRequest
                {
                    SearchRequestId = validRequestId
                }
            };

            _fakeName = new AliasEntity
            {
                SearchRequest = new SSG_SearchRequest
                {
                    SearchRequestId = validRequestId
                }
            };

            _ssg_fakePerson = new PersonEntity
            {
            };

            _searchRequest = new SSG_SearchRequest
            {
                SearchRequestId = validRequestId
            };

            _fakeBankInfo = new BankingInformationEntity
            {
                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"
            };

            _fakeWorkSafeBcClaim = new CompensationClaimEntity()
            {
                SearchRequest      = _searchRequest,
                ClaimNumber        = "claimNumber",
                BankingInformation = new SSG_Asset_BankingInformation()
                {
                    BankingInformationId = validBankInformationId
                },
                Employment = new SSG_Employment()
                {
                    EmploymentId = validEmploymentId
                }
            };

            _fakeCompensationEmployment = new EmploymentEntity()
            {
                BusinessName = COMPENSATION_BUISNESS_NAME
            };

            _fakeIcbcClaim = new ICBCClaimEntity()
            {
                ClaimNumber = "icbcClaimNumber"
            };

            _fakeInvolvedParty = new SSG_InvolvedParty()
            {
                OrganizationName = "name"
            };

            _fakeSimplePhone = new SSG_SimplePhoneNumber()
            {
                PhoneNumber = "0"
            };

            _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 <InvolvedParty>()
                        {
                            new InvolvedParty()
                            {
                            }
                        }
                    }
                },
                OtherAssets = new List <OtherAsset>()
                {
                    new OtherAsset()
                    {
                        Owners = new List <InvolvedParty>()
                        {
                            new InvolvedParty()
                            {
                            }
                        }
                    }
                },
                CompensationClaims = new List <CompensationClaim>()
                {
                    new CompensationClaim()
                    {
                        ClaimNumber = "claimNumber",
                        BankInfo    = new BankInfo()
                        {
                            BankName = "compensationBankName"
                        },
                        Employer = new Employer()
                        {
                            Name = COMPENSATION_BUISNESS_NAME
                        },
                        ReferenceDates = new ReferenceDate[]
                        {
                            new ReferenceDate()
                            {
                                Index = 0, Key = "Start Date", Value = new DateTime(2019, 9, 1)
                            }
                        }
                    }
                },
                InsuranceClaims = new List <InsuranceClaim>()
                {
                    new InsuranceClaim()
                    {
                        ClaimNumber    = "icbcClaimNumber",
                        InsuredParties = new List <InvolvedParty>()
                        {
                            new InvolvedParty()
                            {
                                Organization = "insuranceClaimOrg"
                            }
                        },
                        ClaimCentre = new ClaimCentre()
                        {
                            ContactNumber = new List <Phone>()
                            {
                                new Phone()
                                {
                                    PhoneNumber = "9999"
                                }
                            }
                        }
                    }
                }
            };

            _providerProfile = new ProviderProfile()
            {
                Name = "Other"
            };


            _fakeToken = new CancellationToken();

            _mapper.Setup(m => m.Map <IdentifierEntity>(It.IsAny <PersonalIdentifier>()))
            .Returns(_fakePersoneIdentifier);

            _mapper.Setup(m => m.Map <PhoneNumberEntity>(It.IsAny <Phone>()))
            .Returns(_fakePersonPhoneNumber);

            _mapper.Setup(m => m.Map <AddressEntity>(It.IsAny <Address>()))
            .Returns(_fakePersonAddress);

            _mapper.Setup(m => m.Map <AliasEntity>(It.IsAny <Name>()))
            .Returns(_fakeName);

            _mapper.Setup(m => m.Map <PersonEntity>(It.IsAny <Person>()))
            .Returns(_ssg_fakePerson);

            _mapper.Setup(m => m.Map <EmploymentEntity>(It.Is <Employer>(m => m.Name == COMPENSATION_BUISNESS_NAME)))
            .Returns(_fakeCompensationEmployment);

            _mapper.Setup(m => m.Map <EmploymentEntity>(It.IsAny <Employment>()))
            .Returns(_fakeEmployment);

            _mapper.Setup(m => m.Map <EmploymentContactEntity>(It.IsAny <Phone>()))
            .Returns(_fakeEmploymentContact);

            _mapper.Setup(m => m.Map <RelatedPersonEntity>(It.IsAny <RelatedPerson>()))
            .Returns(_fakeRelatedPerson);

            _mapper.Setup(m => m.Map <BankingInformationEntity>(It.IsAny <BankInfo>()))
            .Returns(_fakeBankInfo);

            _mapper.Setup(m => m.Map <VehicleEntity>(It.IsAny <Vehicle>()))
            .Returns(_fakeVehicleEntity);

            _mapper.Setup(m => m.Map <AssetOwnerEntity>(It.IsAny <InvolvedParty>()))
            .Returns(_fakeAssetOwner);

            _mapper.Setup(m => m.Map <AssetOtherEntity>(It.IsAny <OtherAsset>()))
            .Returns(_fakeOtherAsset);

            _mapper.Setup(m => m.Map <CompensationClaimEntity>(It.IsAny <CompensationClaim>()))
            .Returns(_fakeWorkSafeBcClaim);

            _mapper.Setup(m => m.Map <ICBCClaimEntity>(It.IsAny <InsuranceClaim>()))
            .Returns(_fakeIcbcClaim);

            _mapper.Setup(m => m.Map <InvolvedPartyEntity>(It.Is <InvolvedParty>(m => m.Organization == "insuranceClaimOrg")))
            .Returns(_fakeInvolvedParty);

            _mapper.Setup(m => m.Map <SimplePhoneNumberEntity>(It.Is <Phone>(m => m.PhoneNumber == "9999")))
            .Returns(_fakeSimplePhone);

            _searchRequestServiceMock.Setup(x => x.CreateIdentifier(It.IsAny <IdentifierEntity>(), It.IsAny <CancellationToken>()))
            .Returns(Task.FromResult <SSG_Identifier>(new SSG_Identifier()
            {
            }));

            _searchRequestServiceMock.Setup(x => x.CreateAddress(It.Is <AddressEntity>(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 <PhoneNumberEntity>(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 <AliasEntity>(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 <EmploymentContactEntity>(), It.IsAny <CancellationToken>()))
            .Returns(Task.FromResult <SSG_EmploymentContact>(new SSG_EmploymentContact()
            {
                PhoneNumber = "4007678231"
            }));

            _searchRequestServiceMock.Setup(x => x.CreateRelatedPerson(It.Is <RelatedPersonEntity>(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 <BankingInformationEntity>(x => x.SearchRequest.SearchRequestId == validRequestId), It.IsAny <CancellationToken>()))
            .Returns(Task.FromResult <SSG_Asset_BankingInformation>(new SSG_Asset_BankingInformation()
            {
                BankingInformationId = validBankInformationId,
                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
            }));

            _searchRequestServiceMock.Setup(x => x.CreateCompensationClaim(It.Is <CompensationClaimEntity>(x => x.SearchRequest.SearchRequestId == validRequestId), It.IsAny <CancellationToken>()))
            .Returns(Task.FromResult <SSG_Asset_WorkSafeBcClaim>(new SSG_Asset_WorkSafeBcClaim()
            {
                ClaimNumber = "claimNumber"
            }));

            _searchRequestServiceMock.Setup(x => x.CreateEmployment(It.Is <EmploymentEntity>(x => x.BusinessName == COMPENSATION_BUISNESS_NAME && x.Date1 == new DateTime(2019, 9, 1)), It.IsAny <CancellationToken>()))
            .Returns(Task.FromResult <SSG_Employment>(new SSG_Employment()
            {
                EmploymentId = Guid.NewGuid(),
            }));

            _searchRequestServiceMock.Setup(x => x.CreateInsuranceClaim(It.Is <ICBCClaimEntity>(x => x.SearchRequest.SearchRequestId == validRequestId), It.IsAny <CancellationToken>()))
            .Returns(Task.FromResult <SSG_Asset_ICBCClaim>(new SSG_Asset_ICBCClaim()
            {
                ICBCClaimId = Guid.NewGuid()
            }));

            _searchRequestServiceMock.Setup(x => x.CreateInvolvedParty(It.IsAny <SSG_InvolvedParty>(), It.IsAny <CancellationToken>()))
            .Returns(Task.FromResult <SSG_InvolvedParty>(new SSG_InvolvedParty()
            {
            }));

            _searchRequestServiceMock.Setup(x => x.CreateSimplePhoneNumber(It.IsAny <SSG_SimplePhoneNumber>(), It.IsAny <CancellationToken>()))
            .Returns(Task.FromResult <SSG_SimplePhoneNumber>(new SSG_SimplePhoneNumber()
            {
            }));

            _searchRequestServiceMock.Setup(x => x.CreateTransaction(It.IsAny <SSG_SearchRequestResultTransaction>(), It.IsAny <CancellationToken>()))
            .Returns(Task.FromResult <SSG_SearchRequestResultTransaction>(new SSG_SearchRequestResultTransaction()
            {
            }));

            _sut = new SearchResultService(_searchRequestServiceMock.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);
        }
Exemple #10
0
 public async Task <SSG_Asset_Other> CreateOtherAsset(AssetOtherEntity otherAsset, CancellationToken cancellationToken)
 {
     return(await this._oDataClient.For <SSG_Asset_Other>().Set(otherAsset).InsertEntryAsync(cancellationToken));
 }