public void EndExperimentResourceNames() { moq::Mock <ExperimentService.ExperimentServiceClient> mockGrpcClient = new moq::Mock <ExperimentService.ExperimentServiceClient>(moq::MockBehavior.Strict); mockGrpcClient.Setup(x => x.CreateOperationsClient()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object); EndExperimentRequest request = new EndExperimentRequest { ExperimentAsExperimentName = gagvr::ExperimentName.FromCustomerTrial("[CUSTOMER_ID]", "[TRIAL_ID]"), }; wkt::Empty expectedResponse = new wkt::Empty { }; mockGrpcClient.Setup(x => x.EndExperiment(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse); ExperimentServiceClient client = new ExperimentServiceClientImpl(mockGrpcClient.Object, null); client.EndExperiment(request.ExperimentAsExperimentName); mockGrpcClient.VerifyAll(); }
public async stt::Task EndExperimentResourceNamesAsync() { moq::Mock <ExperimentService.ExperimentServiceClient> mockGrpcClient = new moq::Mock <ExperimentService.ExperimentServiceClient>(moq::MockBehavior.Strict); mockGrpcClient.Setup(x => x.CreateOperationsClient()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object); EndExperimentRequest request = new EndExperimentRequest { ExperimentAsExperimentName = gagvr::ExperimentName.FromCustomerTrial("[CUSTOMER_ID]", "[TRIAL_ID]"), }; wkt::Empty expectedResponse = new wkt::Empty { }; mockGrpcClient.Setup(x => x.EndExperimentAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <wkt::Empty>(stt::Task.FromResult(expectedResponse), null, null, null, null)); ExperimentServiceClient client = new ExperimentServiceClientImpl(mockGrpcClient.Object, null); await client.EndExperimentAsync(request.ExperimentAsExperimentName, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None)); await client.EndExperimentAsync(request.ExperimentAsExperimentName, st::CancellationToken.None); mockGrpcClient.VerifyAll(); }