Exemplo n.º 1
0
        public async stt::Task MutateCampaignSharedSetsAsync()
        {
            moq::Mock <CampaignSharedSetService.CampaignSharedSetServiceClient> mockGrpcClient = new moq::Mock <CampaignSharedSetService.CampaignSharedSetServiceClient>(moq::MockBehavior.Strict);
            MutateCampaignSharedSetsRequest request = new MutateCampaignSharedSetsRequest
            {
                CustomerId = "customer_id3b3724cb",
                Operations =
                {
                    new CampaignSharedSetOperation(),
                },
            };
            MutateCampaignSharedSetsResponse expectedResponse = new MutateCampaignSharedSetsResponse
            {
                Results =
                {
                    new MutateCampaignSharedSetResult(),
                },
                PartialFailureError = new gr::Status(),
            };

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

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

            Assert.AreEqual(expectedResponse, responseCancellationToken);
            mockGrpcClient.VerifyAll();
        }
        public async Task MutateCampaignSharedSetsAsync2()
        {
            Mock <CampaignSharedSetService.CampaignSharedSetServiceClient> mockGrpcClient = new Mock <CampaignSharedSetService.CampaignSharedSetServiceClient>(MockBehavior.Strict);
            MutateCampaignSharedSetsRequest request = new MutateCampaignSharedSetsRequest
            {
                CustomerId = "customerId-1772061412",
                Operations = { },
            };
            MutateCampaignSharedSetsResponse expectedResponse = new MutateCampaignSharedSetsResponse();

            mockGrpcClient.Setup(x => x.MutateCampaignSharedSetsAsync(request, It.IsAny <CallOptions>()))
            .Returns(new Grpc.Core.AsyncUnaryCall <MutateCampaignSharedSetsResponse>(Task.FromResult(expectedResponse), null, null, null, null));
            CampaignSharedSetServiceClient   client   = new CampaignSharedSetServiceClientImpl(mockGrpcClient.Object, null);
            MutateCampaignSharedSetsResponse response = await client.MutateCampaignSharedSetsAsync(request);

            Assert.AreEqual(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
        public async Task MutateCampaignSharedSetsAsync()
        {
            Mock <CampaignSharedSetService.CampaignSharedSetServiceClient> mockGrpcClient = new Mock <CampaignSharedSetService.CampaignSharedSetServiceClient>(MockBehavior.Strict);
            MutateCampaignSharedSetsRequest expectedRequest = new MutateCampaignSharedSetsRequest
            {
                CustomerId     = "customerId-1772061412",
                Operations     = { },
                PartialFailure = true,
                ValidateOnly   = false,
            };
            MutateCampaignSharedSetsResponse expectedResponse = new MutateCampaignSharedSetsResponse();

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

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