コード例 #1
0
        public async stt::Task RunPivotReportRequestObjectAsync()
        {
            moq::Mock <AlphaAnalyticsData.AlphaAnalyticsDataClient> mockGrpcClient = new moq::Mock <AlphaAnalyticsData.AlphaAnalyticsDataClient>(moq::MockBehavior.Strict);
            RunPivotReportRequest request = new RunPivotReportRequest
            {
                Entity              = new Entity(),
                Dimensions          = { new Dimension(), },
                Metrics             = { new Metric(), },
                DimensionFilter     = new FilterExpression(),
                MetricFilter        = new FilterExpression(),
                Pivots              = { new Pivot(), },
                DateRanges          = { new DateRange(), },
                CurrencyCode        = "currency_code7f81e352",
                CohortSpec          = new CohortSpec(),
                KeepEmptyRows       = true,
                ReturnPropertyQuota = true,
            };
            RunPivotReportResponse expectedResponse = new RunPivotReportResponse
            {
                PivotHeaders     = { new PivotHeader(), },
                MetricHeaders    = { new MetricHeader(), },
                Rows             = { new Row(), },
                Aggregates       = { new Row(), },
                Metadata         = new ResponseMetaData(),
                PropertyQuota    = new PropertyQuota(),
                DimensionHeaders =
                {
                    new DimensionHeader(),
                },
            };

            mockGrpcClient.Setup(x => x.RunPivotReportAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <RunPivotReportResponse>(stt::Task.FromResult(expectedResponse), null, null, null, null));
            AlphaAnalyticsDataClient client = new AlphaAnalyticsDataClientImpl(mockGrpcClient.Object, null);
            RunPivotReportResponse   responseCallSettings = await client.RunPivotReportAsync(request, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None));

            xunit::Assert.Same(expectedResponse, responseCallSettings);
            RunPivotReportResponse responseCancellationToken = await client.RunPivotReportAsync(request, st::CancellationToken.None);

            xunit::Assert.Same(expectedResponse, responseCancellationToken);
            mockGrpcClient.VerifyAll();
        }
        public async Task RunPivotReportAsync()
        {
            Mock <AlphaAnalyticsData.AlphaAnalyticsDataClient> mockGrpcClient = new Mock <AlphaAnalyticsData.AlphaAnalyticsDataClient>(MockBehavior.Strict);
            RunPivotReportRequest  request          = new RunPivotReportRequest();
            RunPivotReportResponse expectedResponse = new RunPivotReportResponse();

            mockGrpcClient.Setup(x => x.RunPivotReportAsync(request, It.IsAny <CallOptions>()))
            .Returns(new Grpc.Core.AsyncUnaryCall <RunPivotReportResponse>(Task.FromResult(expectedResponse), null, null, null, null));
            AlphaAnalyticsDataClient client   = new AlphaAnalyticsDataClientImpl(mockGrpcClient.Object, null);
            RunPivotReportResponse   response = await client.RunPivotReportAsync(request);

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