private void StubCreateAssetUseCaseWithAddress(string address, string address2) { var assetResponse = new CreateAssetResponse { Asset = new AssetOutputModel { Address = address } }; var assetResponse2 = new CreateAssetResponse { Asset = new AssetOutputModel { Address = address2 } }; _mockBulkCreateAssetUseCase .Setup(s => s.ExecuteAsync( It.Is <IList <CreateAssetRequest> >(req => req[0].Address.Equals(address) || req[1].Address.Equals(address2)), It.IsAny <CancellationToken>())) .ReturnsAsync(new List <CreateAssetResponse> { assetResponse, assetResponse2 }); }
/// <summary> /// Unmarshaller the response from the service to the response class. /// </summary> /// <param name="context"></param> /// <returns></returns> public override AmazonWebServiceResponse Unmarshall(JsonUnmarshallerContext context) { CreateAssetResponse response = new CreateAssetResponse(); context.Read(); int targetDepth = context.CurrentDepth; while (context.ReadAtDepth(targetDepth)) { if (context.TestExpression("assetArn", targetDepth)) { var unmarshaller = StringUnmarshaller.Instance; response.AssetArn = unmarshaller.Unmarshall(context); continue; } if (context.TestExpression("assetId", targetDepth)) { var unmarshaller = StringUnmarshaller.Instance; response.AssetId = unmarshaller.Unmarshall(context); continue; } if (context.TestExpression("assetStatus", targetDepth)) { var unmarshaller = AssetStatusUnmarshaller.Instance; response.AssetStatus = unmarshaller.Unmarshall(context); continue; } } return(response); }
public async Task ThenReturnTheCreatedAssets(string input) { var createAssetResponse = new CreateAssetResponse { Asset = new AssetOutputModel { Address = input } }; _mockBulkCreateAssetUseCase .Setup(s => s.ExecuteAsync(It.IsAny <IList <CreateAssetRequest> >(), It.IsAny <CancellationToken>())) .ReturnsAsync(new List <CreateAssetResponse> { createAssetResponse }); var request = new ImportAssetsRequest { AssetLines = new List <string> { input } }; var results = await _classUnderTest.ExecuteAsync(request, CancellationToken.None).ConfigureAwait(false); var createdAsset = results.AssetsImported[0]; createdAsset.Address.Should().BeEquivalentTo(input); }
public static CreateAssetResponse Unmarshall(UnmarshallerContext _ctx) { CreateAssetResponse createAssetResponse = new CreateAssetResponse(); createAssetResponse.HttpResponse = _ctx.HttpResponse; createAssetResponse.RequestId = _ctx.StringValue("CreateAsset.RequestId"); createAssetResponse.Uuid = _ctx.StringValue("CreateAsset.Uuid"); return(createAssetResponse); }
/// <summary> /// Unmarshaller the response from the service to the response class. /// </summary> /// <param name="context"></param> /// <returns></returns> public override AmazonWebServiceResponse Unmarshall(JsonUnmarshallerContext context) { CreateAssetResponse response = new CreateAssetResponse(); context.Read(); int targetDepth = context.CurrentDepth; while (context.ReadAtDepth(targetDepth)) { if (context.TestExpression("arn", targetDepth)) { var unmarshaller = StringUnmarshaller.Instance; response.Arn = unmarshaller.Unmarshall(context); continue; } if (context.TestExpression("egressEndpoints", targetDepth)) { var unmarshaller = new ListUnmarshaller <EgressEndpoint, EgressEndpointUnmarshaller>(EgressEndpointUnmarshaller.Instance); response.EgressEndpoints = unmarshaller.Unmarshall(context); continue; } if (context.TestExpression("id", targetDepth)) { var unmarshaller = StringUnmarshaller.Instance; response.Id = unmarshaller.Unmarshall(context); continue; } if (context.TestExpression("packagingGroupId", targetDepth)) { var unmarshaller = StringUnmarshaller.Instance; response.PackagingGroupId = unmarshaller.Unmarshall(context); continue; } if (context.TestExpression("resourceId", targetDepth)) { var unmarshaller = StringUnmarshaller.Instance; response.ResourceId = unmarshaller.Unmarshall(context); continue; } if (context.TestExpression("sourceArn", targetDepth)) { var unmarshaller = StringUnmarshaller.Instance; response.SourceArn = unmarshaller.Unmarshall(context); continue; } if (context.TestExpression("sourceRoleArn", targetDepth)) { var unmarshaller = StringUnmarshaller.Instance; response.SourceRoleArn = unmarshaller.Unmarshall(context); continue; } } return(response); }
public async Task <String> CreateAssetAsync(String type, dynamic assetObject) { HttpContent requestContent = HttpHelper.SerializeRequestContent(new CreateAssetRequest(type, assetObject)); HttpResponseMessage httpResponse = await this.http.PostAsync(BlockchainConstants.BASE_URL + BlockchainConstants.ASSET, requestContent); CreateAssetResponse createAssetResponse = await HttpHelper.DeserializeHttpResponse <CreateAssetResponse>(httpResponse); if (!createAssetResponse.Ok) { throw new Exception(); } return(createAssetResponse.Id); }
private void StubCreateAssetUseCase() { var createAssetResponse = new CreateAssetResponse { Asset = new AssetOutputModel { Address = "Test" } }; _mockBulkCreateAssetUseCase .Setup(s => s.ExecuteAsync(It.IsAny <IList <CreateAssetRequest> >(), It.IsAny <CancellationToken>())) .ReturnsAsync(new List <CreateAssetResponse> { createAssetResponse }); }
public async Task <CreateAssetResponse> ExecuteAsync(CreateAssetRequest requests, CancellationToken cancellationToken) { IAsset asset = new Asset(requests); var createdAsset = await _assetCreator.CreateAsync(asset); if (createdAsset == null) { throw new CreateAssetException(); } var assetOutputModel = new AssetOutputModel(createdAsset); var createdAssetResponse = new CreateAssetResponse { Asset = assetOutputModel }; return(createdAssetResponse); }
private void ExpectFoundAssetIsEqual(SearchAssetResponse foundAsset, CreateAssetResponse createdAsset) { foundAsset.Should().NotBeNull(); foundAsset.Assets.Should().NotBeNullOrEmpty(); foundAsset.Assets.ElementAt(0).AssetOutputModelIsEqual(createdAsset.Asset); }