public async Task GetDatasetAsync2()
        {
            Mock <AutoMl.AutoMlClient> mockGrpcClient = new Mock <AutoMl.AutoMlClient>(MockBehavior.Strict);

            mockGrpcClient.Setup(x => x.CreateOperationsClient())
            .Returns(new Mock <Operations.OperationsClient>().Object);
            GetDatasetRequest request = new GetDatasetRequest
            {
                DatasetName = new DatasetName("[PROJECT]", "[LOCATION]", "[DATASET]"),
            };
            Dataset expectedResponse = new Dataset
            {
                Name         = "name2-1052831874",
                DisplayName  = "displayName1615086568",
                Description  = "description-1724546052",
                ExampleCount = 1517063674,
                Etag         = "etag3123477",
            };

            mockGrpcClient.Setup(x => x.GetDatasetAsync(request, It.IsAny <CallOptions>()))
            .Returns(new Grpc.Core.AsyncUnaryCall <Dataset>(Task.FromResult(expectedResponse), null, null, null, null));
            AutoMlClient client   = new AutoMlClientImpl(mockGrpcClient.Object, null);
            Dataset      response = await client.GetDatasetAsync(request);

            Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
예제 #2
0
        public async stt::Task GetDatasetRequestObjectAsync()
        {
            moq::Mock <AutoMl.AutoMlClient> mockGrpcClient = new moq::Mock <AutoMl.AutoMlClient>(moq::MockBehavior.Strict);

            mockGrpcClient.Setup(x => x.CreateOperationsClient()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object);
            GetDatasetRequest request = new GetDatasetRequest
            {
                Name = "name1c9368b0",
            };
            Dataset expectedResponse = new Dataset
            {
                Name         = "name1c9368b0",
                DisplayName  = "display_name137f65c2",
                Description  = "description2cf9da67",
                CreateTime   = new wkt::Timestamp(),
                Etag         = "etage8ad7218",
                ExampleCount = -1179891861,
                TranslationDatasetMetadata          = new TranslationDatasetMetadata(),
                ImageClassificationDatasetMetadata  = new ImageClassificationDatasetMetadata(),
                TextClassificationDatasetMetadata   = new TextClassificationDatasetMetadata(),
                ImageObjectDetectionDatasetMetadata = new ImageObjectDetectionDatasetMetadata(),
                TextExtractionDatasetMetadata       = new TextExtractionDatasetMetadata(),
                TextSentimentDatasetMetadata        = new TextSentimentDatasetMetadata(),
                Labels =
                {
                    {
                        "key8a0b6e3c",
                        "value60c16320"
                    },
                },
            };

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

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

            xunit::Assert.Same(expectedResponse, responseCancellationToken);
            mockGrpcClient.VerifyAll();
        }