Exemplo n.º 1
0
        public async stt::Task AddMutateJobOperations2ResourceNamesAsync()
        {
            moq::Mock <MutateJobService.MutateJobServiceClient> mockGrpcClient = new moq::Mock <MutateJobService.MutateJobServiceClient>(moq::MockBehavior.Strict);

            mockGrpcClient.Setup(x => x.CreateOperationsClient()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object);
            AddMutateJobOperationsRequest request = new AddMutateJobOperationsRequest
            {
                ResourceNameAsMutateJobName = gagvr::MutateJobName.FromCustomerMutateJob("[CUSTOMER]", "[MUTATE_JOB]"),
                MutateOperations            =
                {
                    new MutateOperation(),
                },
            };
            AddMutateJobOperationsResponse expectedResponse = new AddMutateJobOperationsResponse
            {
                TotalOperations   = -8188520186954789005L,
                NextSequenceToken = "next_sequence_token160dabc7",
            };

            mockGrpcClient.Setup(x => x.AddMutateJobOperationsAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <AddMutateJobOperationsResponse>(stt::Task.FromResult(expectedResponse), null, null, null, null));
            MutateJobServiceClient         client = new MutateJobServiceClientImpl(mockGrpcClient.Object, null);
            AddMutateJobOperationsResponse responseCallSettings = await client.AddMutateJobOperationsAsync(request.ResourceNameAsMutateJobName, request.MutateOperations, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None));

            Assert.AreEqual(expectedResponse, responseCallSettings);
            AddMutateJobOperationsResponse responseCancellationToken = await client.AddMutateJobOperationsAsync(request.ResourceNameAsMutateJobName, request.MutateOperations, st::CancellationToken.None);

            Assert.AreEqual(expectedResponse, responseCancellationToken);
            mockGrpcClient.VerifyAll();
        }
Exemplo n.º 2
0
        public void AddMutateJobOperations2ResourceNames()
        {
            moq::Mock <MutateJobService.MutateJobServiceClient> mockGrpcClient = new moq::Mock <MutateJobService.MutateJobServiceClient>(moq::MockBehavior.Strict);

            mockGrpcClient.Setup(x => x.CreateOperationsClient()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object);
            AddMutateJobOperationsRequest request = new AddMutateJobOperationsRequest
            {
                ResourceNameAsMutateJobName = gagvr::MutateJobName.FromCustomerMutateJob("[CUSTOMER]", "[MUTATE_JOB]"),
                MutateOperations            =
                {
                    new MutateOperation(),
                },
            };
            AddMutateJobOperationsResponse expectedResponse = new AddMutateJobOperationsResponse
            {
                TotalOperations   = -8188520186954789005L,
                NextSequenceToken = "next_sequence_token160dabc7",
            };

            mockGrpcClient.Setup(x => x.AddMutateJobOperations(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse);
            MutateJobServiceClient         client   = new MutateJobServiceClientImpl(mockGrpcClient.Object, null);
            AddMutateJobOperationsResponse response = client.AddMutateJobOperations(request.ResourceNameAsMutateJobName, request.MutateOperations);

            Assert.AreEqual(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
Exemplo n.º 3
0
        public void AddMutateJobOperations()
        {
            Mock <MutateJobService.MutateJobServiceClient> mockGrpcClient = new Mock <MutateJobService.MutateJobServiceClient>(MockBehavior.Strict);

            mockGrpcClient.Setup(x => x.CreateOperationsClient())
            .Returns(new Mock <Operations.OperationsClient>().Object);
            AddMutateJobOperationsRequest expectedRequest = new AddMutateJobOperationsRequest
            {
                ResourceName     = new MutateJobName("[CUSTOMER]", "[MUTATE_JOB]").ToString(),
                SequenceToken    = "sequenceToken-868155397",
                MutateOperations = { },
            };
            AddMutateJobOperationsResponse expectedResponse = new AddMutateJobOperationsResponse
            {
                TotalOperations   = 1685086151L,
                NextSequenceToken = "nextSequenceToken388644551",
            };

            mockGrpcClient.Setup(x => x.AddMutateJobOperations(expectedRequest, It.IsAny <CallOptions>()))
            .Returns(expectedResponse);
            MutateJobServiceClient client = new MutateJobServiceClientImpl(mockGrpcClient.Object, null);
            string formattedResourceName  = new MutateJobName("[CUSTOMER]", "[MUTATE_JOB]").ToString();
            string sequenceToken          = "sequenceToken-868155397";
            IEnumerable <MutateOperation>  mutateOperations = new List <MutateOperation>();
            AddMutateJobOperationsResponse response         = client.AddMutateJobOperations(formattedResourceName, sequenceToken, mutateOperations);

            Assert.AreEqual(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
Exemplo n.º 4
0
        public async Task AddMutateJobOperationsAsync2()
        {
            Mock <MutateJobService.MutateJobServiceClient> mockGrpcClient = new Mock <MutateJobService.MutateJobServiceClient>(MockBehavior.Strict);

            mockGrpcClient.Setup(x => x.CreateOperationsClient())
            .Returns(new Mock <Operations.OperationsClient>().Object);
            AddMutateJobOperationsRequest request = new AddMutateJobOperationsRequest
            {
                ResourceName     = new MutateJobName("[CUSTOMER]", "[MUTATE_JOB]").ToString(),
                SequenceToken    = "sequenceToken-868155397",
                MutateOperations = { },
            };
            AddMutateJobOperationsResponse expectedResponse = new AddMutateJobOperationsResponse
            {
                TotalOperations   = 1685086151L,
                NextSequenceToken = "nextSequenceToken388644551",
            };

            mockGrpcClient.Setup(x => x.AddMutateJobOperationsAsync(request, It.IsAny <CallOptions>()))
            .Returns(new Grpc.Core.AsyncUnaryCall <AddMutateJobOperationsResponse>(Task.FromResult(expectedResponse), null, null, null, null));
            MutateJobServiceClient         client   = new MutateJobServiceClientImpl(mockGrpcClient.Object, null);
            AddMutateJobOperationsResponse response = await client.AddMutateJobOperationsAsync(request);

            Assert.AreEqual(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
Exemplo n.º 5
0
        /// <summary>
        /// Adds all mutate job operations to the mutate job. As this is the first time for this
        /// mutate job, the sequence token is not set. The response will contain the next sequence
        /// token that you can use to upload more operations in the future.
        /// </summary>
        /// <param name="mutateJobService">The mutate job service.</param>
        /// <param name="customerId">The Google Ads customer ID for which the call is made.</param>
        /// <param name="mutateJobResourceName">The resource name of mutate job to which the mutate
        /// job operations will be added.
        /// </param>
        private static void AddAllMutateJobOperations(MutateJobServiceClient mutateJobService,
                                                      long customerId, string mutateJobResourceName)
        {
            AddMutateJobOperationsResponse response =
                mutateJobService.AddMutateJobOperations(
                    new AddMutateJobOperationsRequest()
            {
                ResourceName     = mutateJobResourceName,
                MutateOperations = { BuildAllOperations(customerId) }
            });

            Console.WriteLine($"{response.TotalOperations} mutate operations have been added" +
                              $" so far.");

            // You can use this next sequence token for calling AddMutateJobOperations() next time.
            Console.WriteLine($"Next sequence token for adding next operations is " +
                              $"'{response.NextSequenceToken}'.");
        }