public void MutateAdGroupAssets() { moq::Mock <AdGroupAssetService.AdGroupAssetServiceClient> mockGrpcClient = new moq::Mock <AdGroupAssetService.AdGroupAssetServiceClient>(moq::MockBehavior.Strict); MutateAdGroupAssetsRequest request = new MutateAdGroupAssetsRequest { CustomerId = "customer_id3b3724cb", Operations = { new AdGroupAssetOperation(), }, }; MutateAdGroupAssetsResponse expectedResponse = new MutateAdGroupAssetsResponse { PartialFailureError = new gr::Status(), Results = { new MutateAdGroupAssetResult(), }, }; mockGrpcClient.Setup(x => x.MutateAdGroupAssets(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse); AdGroupAssetServiceClient client = new AdGroupAssetServiceClientImpl(mockGrpcClient.Object, null); MutateAdGroupAssetsResponse response = client.MutateAdGroupAssets(request.CustomerId, request.Operations); Assert.AreEqual(expectedResponse, response); mockGrpcClient.VerifyAll(); }
public async stt::Task MutateAdGroupAssetsRequestObjectAsync() { moq::Mock <AdGroupAssetService.AdGroupAssetServiceClient> mockGrpcClient = new moq::Mock <AdGroupAssetService.AdGroupAssetServiceClient>(moq::MockBehavior.Strict); MutateAdGroupAssetsRequest request = new MutateAdGroupAssetsRequest { CustomerId = "customer_id3b3724cb", Operations = { new AdGroupAssetOperation(), }, PartialFailure = false, ValidateOnly = true, ResponseContentType = gagve::ResponseContentTypeEnum.Types.ResponseContentType.ResourceNameOnly, }; MutateAdGroupAssetsResponse expectedResponse = new MutateAdGroupAssetsResponse { PartialFailureError = new gr::Status(), Results = { new MutateAdGroupAssetResult(), }, }; mockGrpcClient.Setup(x => x.MutateAdGroupAssetsAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <MutateAdGroupAssetsResponse>(stt::Task.FromResult(expectedResponse), null, null, null, null)); AdGroupAssetServiceClient client = new AdGroupAssetServiceClientImpl(mockGrpcClient.Object, null); MutateAdGroupAssetsResponse responseCallSettings = await client.MutateAdGroupAssetsAsync(request, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None)); Assert.AreEqual(expectedResponse, responseCallSettings); MutateAdGroupAssetsResponse responseCancellationToken = await client.MutateAdGroupAssetsAsync(request, st::CancellationToken.None); Assert.AreEqual(expectedResponse, responseCancellationToken); mockGrpcClient.VerifyAll(); }
public async stt::Task GetAdGroupAssetRequestObjectAsync() { moq::Mock <AdGroupAssetService.AdGroupAssetServiceClient> mockGrpcClient = new moq::Mock <AdGroupAssetService.AdGroupAssetServiceClient>(moq::MockBehavior.Strict); GetAdGroupAssetRequest request = new GetAdGroupAssetRequest { ResourceNameAsAdGroupAssetName = gagvr::AdGroupAssetName.FromCustomerAdGroupAssetFieldType("[CUSTOMER_ID]", "[AD_GROUP_ID]", "[ASSET_ID]", "[FIELD_TYPE]"), }; gagvr::AdGroupAsset expectedResponse = new gagvr::AdGroupAsset { ResourceNameAsAdGroupAssetName = gagvr::AdGroupAssetName.FromCustomerAdGroupAssetFieldType("[CUSTOMER_ID]", "[AD_GROUP_ID]", "[ASSET_ID]", "[FIELD_TYPE]"), AdGroupAsAdGroupName = gagvr::AdGroupName.FromCustomerAdGroup("[CUSTOMER_ID]", "[AD_GROUP_ID]"), AssetAsAssetName = gagvr::AssetName.FromCustomerAsset("[CUSTOMER_ID]", "[ASSET_ID]"), FieldType = gagve::AssetFieldTypeEnum.Types.AssetFieldType.YoutubeVideo, Status = gagve::AssetLinkStatusEnum.Types.AssetLinkStatus.Paused, }; mockGrpcClient.Setup(x => x.GetAdGroupAssetAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <gagvr::AdGroupAsset>(stt::Task.FromResult(expectedResponse), null, null, null, null)); AdGroupAssetServiceClient client = new AdGroupAssetServiceClientImpl(mockGrpcClient.Object, null); gagvr::AdGroupAsset responseCallSettings = await client.GetAdGroupAssetAsync(request, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None)); xunit::Assert.Same(expectedResponse, responseCallSettings); gagvr::AdGroupAsset responseCancellationToken = await client.GetAdGroupAssetAsync(request, st::CancellationToken.None); xunit::Assert.Same(expectedResponse, responseCancellationToken); mockGrpcClient.VerifyAll(); }
public void GetAdGroupAsset() { moq::Mock <AdGroupAssetService.AdGroupAssetServiceClient> mockGrpcClient = new moq::Mock <AdGroupAssetService.AdGroupAssetServiceClient>(moq::MockBehavior.Strict); GetAdGroupAssetRequest request = new GetAdGroupAssetRequest { ResourceNameAsAdGroupAssetName = gagvr::AdGroupAssetName.FromCustomerAdGroupAssetFieldType("[CUSTOMER_ID]", "[AD_GROUP_ID]", "[ASSET_ID]", "[FIELD_TYPE]"), }; gagvr::AdGroupAsset expectedResponse = new gagvr::AdGroupAsset { ResourceNameAsAdGroupAssetName = gagvr::AdGroupAssetName.FromCustomerAdGroupAssetFieldType("[CUSTOMER_ID]", "[AD_GROUP_ID]", "[ASSET_ID]", "[FIELD_TYPE]"), AdGroupAsAdGroupName = gagvr::AdGroupName.FromCustomerAdGroup("[CUSTOMER_ID]", "[AD_GROUP_ID]"), AssetAsAssetName = gagvr::AssetName.FromCustomerAsset("[CUSTOMER_ID]", "[ASSET_ID]"), FieldType = gagve::AssetFieldTypeEnum.Types.AssetFieldType.YoutubeVideo, Status = gagve::AssetLinkStatusEnum.Types.AssetLinkStatus.Paused, }; mockGrpcClient.Setup(x => x.GetAdGroupAsset(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse); AdGroupAssetServiceClient client = new AdGroupAssetServiceClientImpl(mockGrpcClient.Object, null); gagvr::AdGroupAsset response = client.GetAdGroupAsset(request.ResourceName); xunit::Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }