Beispiel #1
0
        public async stt::Task GetMutateJobResourceNamesAsync()
        {
            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);
            GetMutateJobRequest request = new GetMutateJobRequest
            {
                ResourceNameAsMutateJobName = gagvr::MutateJobName.FromCustomerMutateJob("[CUSTOMER]", "[MUTATE_JOB]"),
            };
            gagvr::MutateJob expectedResponse = new gagvr::MutateJob
            {
                ResourceNameAsMutateJobName = gagvr::MutateJobName.FromCustomerMutateJob("[CUSTOMER]", "[MUTATE_JOB]"),
                Id = -6774108720365892680L,
                NextAddSequenceToken = "next_add_sequence_token93fee49d",
                Metadata             = new gagvr::MutateJob.Types.MutateJobMetadata(),
                Status = gagve::MutateJobStatusEnum.Types.MutateJobStatus.Done,
                LongRunningOperation = "long_running_operation0897bd41",
            };

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

            Assert.AreEqual(expectedResponse, responseCallSettings);
            gagvr::MutateJob responseCancellationToken = await client.GetMutateJobAsync(request.ResourceNameAsMutateJobName, st::CancellationToken.None);

            Assert.AreEqual(expectedResponse, responseCancellationToken);
            mockGrpcClient.VerifyAll();
        }
Beispiel #2
0
        public async Task GetMutateJobAsync2()
        {
            Mock <MutateJobService.MutateJobServiceClient> mockGrpcClient = new Mock <MutateJobService.MutateJobServiceClient>(MockBehavior.Strict);

            mockGrpcClient.Setup(x => x.CreateOperationsClient())
            .Returns(new Mock <Operations.OperationsClient>().Object);
            GetMutateJobRequest request = new GetMutateJobRequest
            {
                ResourceName = new MutateJobName("[CUSTOMER]", "[MUTATE_JOB]").ToString(),
            };
            MutateJob expectedResponse = new MutateJob
            {
                ResourceName = "resourceName2625949903",
            };

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

            Assert.AreEqual(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
Beispiel #3
0
        public void GetMutateJob()
        {
            Mock <MutateJobService.MutateJobServiceClient> mockGrpcClient = new Mock <MutateJobService.MutateJobServiceClient>(MockBehavior.Strict);

            mockGrpcClient.Setup(x => x.CreateOperationsClient())
            .Returns(new Mock <Operations.OperationsClient>().Object);
            GetMutateJobRequest expectedRequest = new GetMutateJobRequest
            {
                ResourceName = new MutateJobName("[CUSTOMER]", "[MUTATE_JOB]").ToString(),
            };
            MutateJob expectedResponse = new MutateJob
            {
                ResourceName = "resourceName2625949903",
            };

            mockGrpcClient.Setup(x => x.GetMutateJob(expectedRequest, It.IsAny <CallOptions>()))
            .Returns(expectedResponse);
            MutateJobServiceClient client   = new MutateJobServiceClientImpl(mockGrpcClient.Object, null);
            string    formattedResourceName = new MutateJobName("[CUSTOMER]", "[MUTATE_JOB]").ToString();
            MutateJob response = client.GetMutateJob(formattedResourceName);

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