public void CreateMutateJob() { 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); CreateMutateJobRequest request = new CreateMutateJobRequest { CustomerId = "customer_id3b3724cb", }; CreateMutateJobResponse expectedResponse = new CreateMutateJobResponse { ResourceName = "resource_name8cc2e687", }; mockGrpcClient.Setup(x => x.CreateMutateJob(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse); MutateJobServiceClient client = new MutateJobServiceClientImpl(mockGrpcClient.Object, null); CreateMutateJobResponse response = client.CreateMutateJob(request.CustomerId); Assert.AreEqual(expectedResponse, response); mockGrpcClient.VerifyAll(); }
public void CreateMutateJob2() { Mock <MutateJobService.MutateJobServiceClient> mockGrpcClient = new Mock <MutateJobService.MutateJobServiceClient>(MockBehavior.Strict); mockGrpcClient.Setup(x => x.CreateOperationsClient()) .Returns(new Mock <Operations.OperationsClient>().Object); CreateMutateJobRequest request = new CreateMutateJobRequest { CustomerId = "customerId-1772061412", }; CreateMutateJobResponse expectedResponse = new CreateMutateJobResponse { ResourceName = "resourceName979421212", }; mockGrpcClient.Setup(x => x.CreateMutateJob(request, It.IsAny <CallOptions>())) .Returns(expectedResponse); MutateJobServiceClient client = new MutateJobServiceClientImpl(mockGrpcClient.Object, null); CreateMutateJobResponse response = client.CreateMutateJob(request); Assert.AreEqual(expectedResponse, response); mockGrpcClient.VerifyAll(); }
public async Task CreateMutateJobAsync2() { Mock <MutateJobService.MutateJobServiceClient> mockGrpcClient = new Mock <MutateJobService.MutateJobServiceClient>(MockBehavior.Strict); mockGrpcClient.Setup(x => x.CreateOperationsClient()) .Returns(new Mock <Operations.OperationsClient>().Object); CreateMutateJobRequest request = new CreateMutateJobRequest { CustomerId = "customerId-1772061412", }; CreateMutateJobResponse expectedResponse = new CreateMutateJobResponse { ResourceName = "resourceName979421212", }; mockGrpcClient.Setup(x => x.CreateMutateJobAsync(request, It.IsAny <CallOptions>())) .Returns(new Grpc.Core.AsyncUnaryCall <CreateMutateJobResponse>(Task.FromResult(expectedResponse), null, null, null, null)); MutateJobServiceClient client = new MutateJobServiceClientImpl(mockGrpcClient.Object, null); CreateMutateJobResponse response = await client.CreateMutateJobAsync(request); Assert.AreEqual(expectedResponse, response); mockGrpcClient.VerifyAll(); }
public async stt::Task CreateMutateJobRequestObjectAsync() { 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); CreateMutateJobRequest request = new CreateMutateJobRequest { CustomerId = "customer_id3b3724cb", }; CreateMutateJobResponse expectedResponse = new CreateMutateJobResponse { ResourceName = "resource_name8cc2e687", }; mockGrpcClient.Setup(x => x.CreateMutateJobAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <CreateMutateJobResponse>(stt::Task.FromResult(expectedResponse), null, null, null, null)); MutateJobServiceClient client = new MutateJobServiceClientImpl(mockGrpcClient.Object, null); CreateMutateJobResponse responseCallSettings = await client.CreateMutateJobAsync(request, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None)); Assert.AreEqual(expectedResponse, responseCallSettings); CreateMutateJobResponse responseCancellationToken = await client.CreateMutateJobAsync(request, st::CancellationToken.None); Assert.AreEqual(expectedResponse, responseCancellationToken); mockGrpcClient.VerifyAll(); }