public async Task with_non_duplicated_person_CreateOtherAsset_should_return_new_SSG_Asset_Other()
        {
            _testOtherAssetId = Guid.NewGuid();
            _odataClientMock.Setup(x => x.For <SSG_Asset_Other>(null).Set(It.Is <AssetOtherEntity>(x => x.Description == "normal"))
                                   .InsertEntryAsync(It.IsAny <CancellationToken>()))
            .Returns(Task.FromResult(new SSG_Asset_Other()
            {
                Description  = "normal",
                AssetOtherId = _testOtherAssetId
            })
                     );
            var otherAsset = new SSG_Asset_Other()
            {
                Description = "normal",
                Person      = new SSG_Person()
                {
                    IsDuplicated = false
                }
            };

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

            Assert.AreEqual("normal", result.Description);
            Assert.AreEqual(_testOtherAssetId, result.AssetOtherId);
        }
        public async Task with_duplicated_person_not_contains_same_otherAsset_should_return_new_SSG_Asset_Other()
        {
            _testOtherAssetId = Guid.NewGuid();
            _odataClientMock.Setup(x => x.For <SSG_Asset_Other>(null).Set(It.Is <AssetOtherEntity>(x => x.Description == "notContain"))
                                   .InsertEntryAsync(It.IsAny <CancellationToken>()))
            .Returns(Task.FromResult(new SSG_Asset_Other()
            {
                Description  = "notContain",
                AssetOtherId = _testOtherAssetId
            })
                     );
            _duplicateServiceMock.Setup(x => x.Exists(It.Is <SSG_Person>(m => m.PersonId == _testId), It.Is <AssetOtherEntity>(m => m.Description == "notContain")))
            .Returns(Task.FromResult(Guid.Empty));

            var otherAsset = new SSG_Asset_Other()
            {
                Description = "notContain",
                Person      = new SSG_Person()
                {
                    IsDuplicated = true
                }
            };
            var result = await _sut.CreateOtherAsset(otherAsset, CancellationToken.None);

            Assert.AreEqual("notContain", result.Description);
            Assert.AreEqual(_testOtherAssetId, result.AssetOtherId);
        }
        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);
            }
        }
        public void SSG_Other_asset_should_map_to_OtherAsset_correctly()
        {
            SSG_Asset_Other other = new SSG_Asset_Other
            {
                AssetDescription = "assetDesc",
                TypeDescription  = "typeDesc"
            };

            OtherAsset asset = _mapper.Map <OtherAsset>(other);

            Assert.AreEqual("assetDesc", asset.Description);
            Assert.AreEqual("typeDesc", asset.TypeDescription);
        }
Exemple #5
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);
            }
        }