コード例 #1
0
        public void GetDataset2()
        {
            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.GetDataset(request, It.IsAny <CallOptions>()))
            .Returns(expectedResponse);
            AutoMlClient client   = new AutoMlClientImpl(mockGrpcClient.Object, null);
            Dataset      response = client.GetDataset(request);

            Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
コード例 #2
0
        public void GetDatasetRequestObject()
        {
            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.GetDataset(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse);
            AutoMlClient client   = new AutoMlClientImpl(mockGrpcClient.Object, null);
            Dataset      response = client.GetDataset(request);

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