public async Task with_duplicated_insurance_not_contains_same_party_CreateInvolvedParty_should_return_new_SSG_InvolvedParty() { _odataClientMock.Setup(x => x.For <SSG_InvolvedParty>(null).Set(It.Is <InvolvedPartyEntity>(x => x.FirstName == "notContain")) .InsertEntryAsync(It.IsAny <CancellationToken>())) .Returns(Task.FromResult(new SSG_InvolvedParty() { InvolvedPartyId = _testInvolvedPartyId }) ); _duplicateServiceMock.Setup(x => x.Exists(It.Is <SSG_Asset_ICBCClaim>(m => m.ICBCClaimId == _testId), It.Is <InvolvedPartyEntity>(m => m.FirstName == "notContain"))) .Returns(Task.FromResult(Guid.Empty)); var party = new InvolvedPartyEntity() { FirstName = "notContain", SSG_Asset_ICBCClaim = new SSG_Asset_ICBCClaim() { IsDuplicated = true } }; var result = await _sut.CreateInvolvedParty(party, CancellationToken.None); Assert.AreEqual(_testInvolvedPartyId, result.InvolvedPartyId); }
private async Task <bool> UploadInsuranceClaims() { if (_foundPerson.InsuranceClaims == null) { return(true); } try { _logger.LogDebug($"Attempting to create insurance claims records for SearchRequest[{_searchRequest.SearchRequestId}]"); foreach (InsuranceClaim claim in _foundPerson.InsuranceClaims) { ICBCClaimEntity icbcClaim = _mapper.Map <ICBCClaimEntity>(claim); icbcClaim.SearchRequest = _searchRequest; icbcClaim.InformationSource = _providerDynamicsID; icbcClaim.Person = _returnedPerson; SSG_Asset_ICBCClaim ssg_claim = await _searchRequestService.CreateInsuranceClaim(icbcClaim, _cancellationToken); await CreateResultTransaction(ssg_claim); if (claim.ClaimCentre != null && claim.ClaimCentre.ContactNumber != null) { foreach (Phone phone in claim.ClaimCentre.ContactNumber) { SimplePhoneNumberEntity phoneForAsset = _mapper.Map <SimplePhoneNumberEntity>(phone); phoneForAsset.SSG_Asset_ICBCClaim = ssg_claim; await _searchRequestService.CreateSimplePhoneNumber(phoneForAsset, _cancellationToken); } } if (claim.InsuredParties != null) { foreach (InvolvedParty party in claim.InsuredParties) { InvolvedPartyEntity involvedParty = _mapper.Map <InvolvedPartyEntity>(party); involvedParty.SSG_Asset_ICBCClaim = ssg_claim; await _searchRequestService.CreateInvolvedParty(involvedParty, _cancellationToken); } } } return(true); } catch (Exception ex) { LogException(ex); return(false); } }
public async Task <SSG_InvolvedParty> CreateInvolvedParty(InvolvedPartyEntity involvedParty, CancellationToken cancellationToken) { if (involvedParty.SSG_Asset_ICBCClaim != null && involvedParty.SSG_Asset_ICBCClaim.IsDuplicated) { Guid duplicatedPartyId = await _duplicateDetectService.Exists(involvedParty.SSG_Asset_ICBCClaim, involvedParty); if (duplicatedPartyId != Guid.Empty) { return new SSG_InvolvedParty() { InvolvedPartyId = duplicatedPartyId } } ; } return(await this._oDataClient.For <SSG_InvolvedParty>().Set(involvedParty).InsertEntryAsync(cancellationToken)); }
public async Task with_duplicated_insurance_contains_same_party_CreateInvolvedParty_should_return_original_involvedparty_guid() { Guid originalGuid = Guid.NewGuid(); _duplicateServiceMock.Setup(x => x.Exists(It.Is <SSG_Asset_ICBCClaim>(m => m.ICBCClaimId == _testId), It.Is <InvolvedPartyEntity>(m => m.FirstName == "contains"))) .Returns(Task.FromResult(originalGuid)); var party = new InvolvedPartyEntity() { FirstName = "contains", SSG_Asset_ICBCClaim = new SSG_Asset_ICBCClaim() { ICBCClaimId = _testId, IsDuplicated = true } }; var result = await _sut.CreateInvolvedParty(party, CancellationToken.None); Assert.AreEqual(originalGuid, result.InvolvedPartyId); }
public async Task with_non_duplicated_insurance_CreateInvolvedParty_should_return_new_SSG_InvolvedParty() { _odataClientMock.Setup(x => x.For <SSG_InvolvedParty>(null).Set(It.Is <InvolvedPartyEntity>(x => x.FirstName == "normal")) .InsertEntryAsync(It.IsAny <CancellationToken>())) .Returns(Task.FromResult(new SSG_InvolvedParty() { InvolvedPartyId = _testInvolvedPartyId }) ); var party = new InvolvedPartyEntity() { FirstName = "normal", SSG_Asset_ICBCClaim = new SSG_Asset_ICBCClaim() { IsDuplicated = false } }; var result = await _sut.CreateInvolvedParty(party, CancellationToken.None); Assert.AreEqual(_testInvolvedPartyId, result.InvolvedPartyId); }
public async Task insurance_does_not_contain_same_involvedParty_Exists_should_return_empty_guid() { DuplicateDetectionService._configs = null; Guid existedInvolvedPartyID = Guid.NewGuid(); SSG_Asset_ICBCClaim insurance = new SSG_Asset_ICBCClaim() { SSG_InvolvedParties = new List <SSG_InvolvedParty>() { new SSG_InvolvedParty() { FirstName = "firstname", LastName = "lastname", InvolvedPartyId = existedInvolvedPartyID } }.ToArray() }; InvolvedPartyEntity entity = new InvolvedPartyEntity() { FirstName = "testfirstname", LastName = "lastname" }; Guid guid = await _sut.Exists(insurance, entity); Assert.AreEqual(Guid.Empty, guid); }