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

            mockGrpcClient.Setup(x => x.CreateOperationsClient())
            .Returns(new Mock <Operations.OperationsClient>().Object);
            UpdateDatasetRequest expectedRequest = new UpdateDatasetRequest
            {
                Dataset    = new Dataset(),
                UpdateMask = new FieldMask(),
            };
            Dataset expectedResponse = new Dataset
            {
                Name         = "name3373707",
                DisplayName  = "displayName1615086568",
                Description  = "description-1724546052",
                ExampleCount = 1517063674,
                Etag         = "etag3123477",
            };

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

            Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
Exemplo n.º 2
0
        public async stt::Task UpdateDatasetRequestObjectAsync()
        {
            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);
            UpdateDatasetRequest request = new UpdateDatasetRequest
            {
                Dataset    = new Dataset(),
                UpdateMask = new wkt::FieldMask(),
            };
            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.UpdateDatasetAsync(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.UpdateDatasetAsync(request, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None));

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

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