public void UpdateDataset() { 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.UpdateDataset(expectedRequest, It.IsAny <CallOptions>())) .Returns(expectedResponse); AutoMlClient client = new AutoMlClientImpl(mockGrpcClient.Object, null); Dataset dataset = new Dataset(); FieldMask updateMask = new FieldMask(); Dataset response = client.UpdateDataset(dataset, updateMask); Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }
public void UpdateDatasetRequestObject() { 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.UpdateDataset(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse); AutoMlClient client = new AutoMlClientImpl(mockGrpcClient.Object, null); Dataset response = client.UpdateDataset(request); xunit::Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }