public void GetAssetGroupAsset() { moq::Mock <AssetGroupAssetService.AssetGroupAssetServiceClient> mockGrpcClient = new moq::Mock <AssetGroupAssetService.AssetGroupAssetServiceClient>(moq::MockBehavior.Strict); GetAssetGroupAssetRequest request = new GetAssetGroupAssetRequest { ResourceNameAsAssetGroupAssetName = gagvr::AssetGroupAssetName.FromCustomerAssetGroupAssetFieldType("[CUSTOMER_ID]", "[ASSET_GROUP_ID]", "[ASSET_ID]", "[FIELD_TYPE]"), }; gagvr::AssetGroupAsset expectedResponse = new gagvr::AssetGroupAsset { ResourceNameAsAssetGroupAssetName = gagvr::AssetGroupAssetName.FromCustomerAssetGroupAssetFieldType("[CUSTOMER_ID]", "[ASSET_GROUP_ID]", "[ASSET_ID]", "[FIELD_TYPE]"), AssetGroupAsAssetGroupName = gagvr::AssetGroupName.FromCustomerAssetGroup("[CUSTOMER_ID]", "[ASSET_GROUP_ID]"), AssetAsAssetName = gagvr::AssetName.FromCustomerAsset("[CUSTOMER_ID]", "[ASSET_ID]"), FieldType = gagve::AssetFieldTypeEnum.Types.AssetFieldType.Callout, Status = gagve::AssetLinkStatusEnum.Types.AssetLinkStatus.Paused, PerformanceLabel = gagve::AssetPerformanceLabelEnum.Types.AssetPerformanceLabel.Pending, PolicySummary = new gagvc::PolicySummary(), }; mockGrpcClient.Setup(x => x.GetAssetGroupAsset(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse); AssetGroupAssetServiceClient client = new AssetGroupAssetServiceClientImpl(mockGrpcClient.Object, null); gagvr::AssetGroupAsset response = client.GetAssetGroupAsset(request.ResourceName); Assert.AreEqual(expectedResponse, response); mockGrpcClient.VerifyAll(); }
public async stt::Task GetAssetGroupAssetRequestObjectAsync() { moq::Mock <AssetGroupAssetService.AssetGroupAssetServiceClient> mockGrpcClient = new moq::Mock <AssetGroupAssetService.AssetGroupAssetServiceClient>(moq::MockBehavior.Strict); GetAssetGroupAssetRequest request = new GetAssetGroupAssetRequest { ResourceNameAsAssetGroupAssetName = gagvr::AssetGroupAssetName.FromCustomerAssetGroupAssetFieldType("[CUSTOMER_ID]", "[ASSET_GROUP_ID]", "[ASSET_ID]", "[FIELD_TYPE]"), }; gagvr::AssetGroupAsset expectedResponse = new gagvr::AssetGroupAsset { ResourceNameAsAssetGroupAssetName = gagvr::AssetGroupAssetName.FromCustomerAssetGroupAssetFieldType("[CUSTOMER_ID]", "[ASSET_GROUP_ID]", "[ASSET_ID]", "[FIELD_TYPE]"), AssetGroupAsAssetGroupName = gagvr::AssetGroupName.FromCustomerAssetGroup("[CUSTOMER_ID]", "[ASSET_GROUP_ID]"), AssetAsAssetName = gagvr::AssetName.FromCustomerAsset("[CUSTOMER_ID]", "[ASSET_ID]"), FieldType = gagve::AssetFieldTypeEnum.Types.AssetFieldType.Callout, Status = gagve::AssetLinkStatusEnum.Types.AssetLinkStatus.Paused, PerformanceLabel = gagve::AssetPerformanceLabelEnum.Types.AssetPerformanceLabel.Pending, PolicySummary = new gagvc::PolicySummary(), }; mockGrpcClient.Setup(x => x.GetAssetGroupAssetAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <gagvr::AssetGroupAsset>(stt::Task.FromResult(expectedResponse), null, null, null, null)); AssetGroupAssetServiceClient client = new AssetGroupAssetServiceClientImpl(mockGrpcClient.Object, null); gagvr::AssetGroupAsset responseCallSettings = await client.GetAssetGroupAssetAsync(request, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None)); Assert.AreEqual(expectedResponse, responseCallSettings); gagvr::AssetGroupAsset responseCancellationToken = await client.GetAssetGroupAssetAsync(request, st::CancellationToken.None); Assert.AreEqual(expectedResponse, responseCancellationToken); mockGrpcClient.VerifyAll(); }