Example #1
0
        public async Task GivenValidRequestId_UseCaseReturnsCorrectlyMappedAsset(int id)
        {
            //arrange
            var asset = TestData.Domain.GenerateAsset();

            asset.Id = id;
            _mockGateway.ReadAsync(id).Returns(asset);
            //act
            var response = await _classUnderTest.ExecuteAsync(new GetAssetRequest
            {
                Id = id
            });

            //assert
            response.Should().NotBeNull();
            response.Asset.Should().NotBeNull();
            response.Asset.AssetOutputModelIsEqual(new AssetOutputModel(asset));
        }
        public async Task <GetAssetResponse> ExecuteAsync(GetAssetRequest request)
        {
            IAsset asset = await _assetReader.ReadAsync(request.Id).ConfigureAwait(false);

            if (asset == null)
            {
                throw new AssetNotFoundException();
            }

            return(new GetAssetResponse
            {
                Asset = new AssetOutputModel(asset)
            });
        }