public async stt::Task GetJobMetricsRequestObjectAsync() { moq::Mock <MetricsV1Beta3.MetricsV1Beta3Client> mockGrpcClient = new moq::Mock <MetricsV1Beta3.MetricsV1Beta3Client>(moq::MockBehavior.Strict); GetJobMetricsRequest request = new GetJobMetricsRequest { ProjectId = "project_id43ad98b0", JobId = "job_id38ea97d6", StartTime = new wkt::Timestamp(), Location = "locatione09d18d5", }; JobMetrics expectedResponse = new JobMetrics { MetricTime = new wkt::Timestamp(), Metrics = { new MetricUpdate(), }, }; mockGrpcClient.Setup(x => x.GetJobMetricsAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <JobMetrics>(stt::Task.FromResult(expectedResponse), null, null, null, null)); MetricsV1Beta3Client client = new MetricsV1Beta3ClientImpl(mockGrpcClient.Object, null); JobMetrics responseCallSettings = await client.GetJobMetricsAsync(request, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None)); xunit::Assert.Same(expectedResponse, responseCallSettings); JobMetrics responseCancellationToken = await client.GetJobMetricsAsync(request, st::CancellationToken.None); xunit::Assert.Same(expectedResponse, responseCancellationToken); mockGrpcClient.VerifyAll(); }
public void GetJobMetricsRequestObject() { moq::Mock <MetricsV1Beta3.MetricsV1Beta3Client> mockGrpcClient = new moq::Mock <MetricsV1Beta3.MetricsV1Beta3Client>(moq::MockBehavior.Strict); GetJobMetricsRequest request = new GetJobMetricsRequest { ProjectId = "project_id43ad98b0", JobId = "job_id38ea97d6", StartTime = new wkt::Timestamp(), Location = "locatione09d18d5", }; JobMetrics expectedResponse = new JobMetrics { MetricTime = new wkt::Timestamp(), Metrics = { new MetricUpdate(), }, }; mockGrpcClient.Setup(x => x.GetJobMetrics(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse); MetricsV1Beta3Client client = new MetricsV1Beta3ClientImpl(mockGrpcClient.Object, null); JobMetrics response = client.GetJobMetrics(request); xunit::Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }