Exemple #1
0
        public async Task GivenValidRequest_UseCaseCallsGatewayWithCorrectDomainObject(int schemeId, int createdAssetId)
        {
            //arrange
            var request = TestData.UseCase.GenerateCreateAssetRequest();

            request.SchemeId = schemeId;
            _gateway.Setup(s => s.CreateAsync(It.IsAny <IAssetRegisterVersion>(), It.IsAny <CancellationToken>()))
            .ReturnsAsync(new AssetRegisterVersion {
                Assets = new List <IAsset>()
                {
                    new Asset(request)
                }
            });

            var list = new List <CreateAssetRequest> {
                request
            };

            //act
            var useCaseResponse = await _classUnderTest.ExecuteAsync(list, CancellationToken.None);

            //assert
            _gateway.Verify(s => s.CreateAsync(It.Is <IAssetRegisterVersion>(i => i.Assets[0].SchemeId.Equals(schemeId)), It.IsAny <CancellationToken>()));
            useCaseResponse.Should().NotBeNull();
            useCaseResponse[0].Asset.Should().NotBeNull();
            useCaseResponse[0].Asset.AssetOutputModelIsEqual(request);
        }
Exemple #2
0
        public async Task <ImportAssetsResponse> ExecuteAsync(ImportAssetsRequest requests, CancellationToken cancellationToken)
        {
            Console.WriteLine($"{DateTime.UtcNow.TimeOfDay.ToString("g")}: Start Creating asset Requests");
            List <CreateAssetRequest> createAssetRequests = new List <CreateAssetRequest>();

            for (int i = 0; i < requests.AssetLines.Count; i++)
            {
                var requestAssetLine   = requests.AssetLines.ElementAtOrDefault(i);
                var createAssetRequest = CreateAssetForLine(requests, cancellationToken, requestAssetLine);
                createAssetRequests.Add(createAssetRequest);
                Console.WriteLine($"{DateTime.UtcNow.TimeOfDay.ToString("g")}: Creating asset Request: {i} of {requests.AssetLines.Count}");
            }
            Console.WriteLine($"{DateTime.UtcNow.TimeOfDay.ToString("g")}: Finished Creating asset Requests");

            Console.WriteLine($"{DateTime.UtcNow.TimeOfDay.ToString("g")}: Start Creating AssetRegisterVersion");
            var responses = await _createAssetRegisterVersionUseCase.ExecuteAsync(createAssetRequests, cancellationToken).ConfigureAwait(false);

            Console.WriteLine($"{DateTime.UtcNow.TimeOfDay.ToString("g")}: Finished Creating AssetRegisterVersion");


            ImportAssetsResponse response = new ImportAssetsResponse
            {
                AssetsImported = responses.Select(s => s.Asset).ToList()
            };

            return(response);
        }
Exemple #3
0
        public async Task GivenWeHaveXUniqueDevelopers_WhenWeGetAllDevelopers_ThenReturnsXUniqueDevelopers(string developer, int count)
        {
            using (var trans = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled))
            {
                var list = new List <CreateAssetRequest>();
                for (var i = 0; i < count; i++)
                {
                    var createAssetRequest = CreateAsset(developer + i);
                    list.Add(createAssetRequest);
                }

                await _createAssetRegisterVersionUseCase.ExecuteAsync(list, CancellationToken.None).ConfigureAwait(false);

                var response = await _classUnderTest.ExecuteAsync(CancellationToken.None).ConfigureAwait(false);

                response.Should().NotBeNull();
                response.Developers.Should().NotBeNullOrEmpty();
                response.Developers.Count.Should().Be(count);
            }
        }
        private async Task <IList <AssetOutputModel> > GenerateAssetsForAggregation(int createdCount, int?schemeId, string address, decimal?agencyFairValue, decimal?agencyEquityValue)
        {
            var list = new List <CreateAssetRequest>();

            for (int i = 0; i < createdCount; i++)
            {
                list.Add(CreateAsset(schemeId, address, agencyFairValue, agencyEquityValue));
            }

            var responses = await _createAssetRegisterVersionUseCase.ExecuteAsync(list, CancellationToken.None).ConfigureAwait(false);

            return(responses.Select(s => s.Asset).ToList());
        }
Exemple #5
0
        public async Task <GenerateAssetsResponse> ExecuteAsync(GenerateAssetsRequest requests, CancellationToken cancellationToken)
        {
            IList <CreateAssetRequest> createAssetRequests = GenerateCreateAssetRequest(requests.Records.Value);

            IList <CreateAssetResponse> response = await _createAssetRegisterVersionUseCase.ExecuteAsync(createAssetRequests, cancellationToken)
                                                   .ConfigureAwait(false);

            var generateAssetsResponse = new GenerateAssetsResponse
            {
                RecordsGenerated = response?.Select(s => s.Asset).ToList()
            };

            return(generateAssetsResponse);
        }
        public async Task GivenAnAssetHasBeenCreated_WhenWeSearch_ThenWeCanFindTheSameAsset(int?schemeId, string address, string searchAddress)
        {
            //arrange
            using (var trans = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled))
            {
                var list = new List <CreateAssetRequest>
                {
                    CreateAsset(schemeId, address),
                };

                var responses = await _createAssetRegisterVersionUseCase.ExecuteAsync(list, CancellationToken.None).ConfigureAwait(false);

                //act
                var foundAsset = await SearchForAssetAsync(schemeId, searchAddress, responses.GetAssetRegisterVersionId(), null, null);

                //assert
                ExpectFoundAssetIsEqual(foundAsset, responses[0]);

                trans.Dispose();
            }
        }