Exemplo n.º 1
0
        public async stt::Task MutateCampaignBidModifiersAsync()
        {
            moq::Mock <CampaignBidModifierService.CampaignBidModifierServiceClient> mockGrpcClient = new moq::Mock <CampaignBidModifierService.CampaignBidModifierServiceClient>(moq::MockBehavior.Strict);
            MutateCampaignBidModifiersRequest request = new MutateCampaignBidModifiersRequest
            {
                CustomerId = "customer_id3b3724cb",
                Operations =
                {
                    new CampaignBidModifierOperation(),
                },
            };
            MutateCampaignBidModifiersResponse expectedResponse = new MutateCampaignBidModifiersResponse
            {
                Results =
                {
                    new MutateCampaignBidModifierResult(),
                },
                PartialFailureError = new gr::Status(),
            };

            mockGrpcClient.Setup(x => x.MutateCampaignBidModifiersAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <MutateCampaignBidModifiersResponse>(stt::Task.FromResult(expectedResponse), null, null, null, null));
            CampaignBidModifierServiceClient   client = new CampaignBidModifierServiceClientImpl(mockGrpcClient.Object, null);
            MutateCampaignBidModifiersResponse responseCallSettings = await client.MutateCampaignBidModifiersAsync(request.CustomerId, request.Operations, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None));

            Assert.AreEqual(expectedResponse, responseCallSettings);
            MutateCampaignBidModifiersResponse responseCancellationToken = await client.MutateCampaignBidModifiersAsync(request.CustomerId, request.Operations, st::CancellationToken.None);

            Assert.AreEqual(expectedResponse, responseCancellationToken);
            mockGrpcClient.VerifyAll();
        }
        public async Task MutateCampaignBidModifiersAsync3()
        {
            Mock <CampaignBidModifierService.CampaignBidModifierServiceClient> mockGrpcClient = new Mock <CampaignBidModifierService.CampaignBidModifierServiceClient>(MockBehavior.Strict);
            MutateCampaignBidModifiersRequest request = new MutateCampaignBidModifiersRequest
            {
                CustomerId = "customerId-1772061412",
                Operations = { },
            };
            MutateCampaignBidModifiersResponse expectedResponse = new MutateCampaignBidModifiersResponse();

            mockGrpcClient.Setup(x => x.MutateCampaignBidModifiersAsync(request, It.IsAny <CallOptions>()))
            .Returns(new Grpc.Core.AsyncUnaryCall <MutateCampaignBidModifiersResponse>(Task.FromResult(expectedResponse), null, null, null, null));
            CampaignBidModifierServiceClient   client   = new CampaignBidModifierServiceClientImpl(mockGrpcClient.Object, null);
            MutateCampaignBidModifiersResponse response = await client.MutateCampaignBidModifiersAsync(request);

            Assert.AreEqual(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
        public async Task MutateCampaignBidModifiersAsync()
        {
            Mock <CampaignBidModifierService.CampaignBidModifierServiceClient> mockGrpcClient = new Mock <CampaignBidModifierService.CampaignBidModifierServiceClient>(MockBehavior.Strict);
            MutateCampaignBidModifiersRequest expectedRequest = new MutateCampaignBidModifiersRequest
            {
                CustomerId     = "customerId-1772061412",
                Operations     = { },
                PartialFailure = true,
                ValidateOnly   = false,
            };
            MutateCampaignBidModifiersResponse expectedResponse = new MutateCampaignBidModifiersResponse();

            mockGrpcClient.Setup(x => x.MutateCampaignBidModifiersAsync(expectedRequest, It.IsAny <CallOptions>()))
            .Returns(new Grpc.Core.AsyncUnaryCall <MutateCampaignBidModifiersResponse>(Task.FromResult(expectedResponse), null, null, null, null));
            CampaignBidModifierServiceClient client = new CampaignBidModifierServiceClientImpl(mockGrpcClient.Object, null);
            string customerId = "customerId-1772061412";
            IEnumerable <CampaignBidModifierOperation> operations = new List <CampaignBidModifierOperation>();
            bool partialFailure = true;
            bool validateOnly   = false;
            MutateCampaignBidModifiersResponse response = await client.MutateCampaignBidModifiersAsync(customerId, operations, partialFailure, validateOnly);

            Assert.AreEqual(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }