public async stt::Task AllocateQuotaRequestObjectAsync() { moq::Mock <QuotaController.QuotaControllerClient> mockGrpcClient = new moq::Mock <QuotaController.QuotaControllerClient>(moq::MockBehavior.Strict); AllocateQuotaRequest request = new AllocateQuotaRequest { ServiceName = "service_named5df05d5", AllocateOperation = new QuotaOperation(), ServiceConfigId = "service_config_id1616022f", }; AllocateQuotaResponse expectedResponse = new AllocateQuotaResponse { OperationId = "operation_id8a494117", AllocateErrors = { new QuotaError(), }, QuotaMetrics = { new MetricValueSet(), }, ServiceConfigId = "service_config_id1616022f", }; mockGrpcClient.Setup(x => x.AllocateQuotaAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <AllocateQuotaResponse>(stt::Task.FromResult(expectedResponse), null, null, null, null)); QuotaControllerClient client = new QuotaControllerClientImpl(mockGrpcClient.Object, null); AllocateQuotaResponse responseCallSettings = await client.AllocateQuotaAsync(request, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None)); xunit::Assert.Same(expectedResponse, responseCallSettings); AllocateQuotaResponse responseCancellationToken = await client.AllocateQuotaAsync(request, st::CancellationToken.None); xunit::Assert.Same(expectedResponse, responseCancellationToken); mockGrpcClient.VerifyAll(); }
public void AllocateQuotaRequestObject() { moq::Mock <QuotaController.QuotaControllerClient> mockGrpcClient = new moq::Mock <QuotaController.QuotaControllerClient>(moq::MockBehavior.Strict); AllocateQuotaRequest request = new AllocateQuotaRequest { ServiceName = "service_named5df05d5", AllocateOperation = new QuotaOperation(), ServiceConfigId = "service_config_id1616022f", }; AllocateQuotaResponse expectedResponse = new AllocateQuotaResponse { OperationId = "operation_id8a494117", AllocateErrors = { new QuotaError(), }, QuotaMetrics = { new MetricValueSet(), }, ServiceConfigId = "service_config_id1616022f", }; mockGrpcClient.Setup(x => x.AllocateQuota(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse); QuotaControllerClient client = new QuotaControllerClientImpl(mockGrpcClient.Object, null); AllocateQuotaResponse response = client.AllocateQuota(request); xunit::Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }