public void GetModel2() { Mock <AutoMl.AutoMlClient> mockGrpcClient = new Mock <AutoMl.AutoMlClient>(MockBehavior.Strict); mockGrpcClient.Setup(x => x.CreateOperationsClient()) .Returns(new Mock <Operations.OperationsClient>().Object); GetModelRequest request = new GetModelRequest { ModelName = new ModelName("[PROJECT]", "[LOCATION]", "[MODEL]"), }; Model expectedResponse = new Model { Name = "name2-1052831874", DisplayName = "displayName1615086568", DatasetId = "datasetId-2115646910", Etag = "etag3123477", }; mockGrpcClient.Setup(x => x.GetModel(request, It.IsAny <CallOptions>())) .Returns(expectedResponse); AutoMlClient client = new AutoMlClientImpl(mockGrpcClient.Object, null); Model response = client.GetModel(request); Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }
public void GetModelRequestObject() { 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); GetModelRequest request = new GetModelRequest { Name = "name1c9368b0", }; Model expectedResponse = new Model { ModelName = ModelName.FromProjectLocationModel("[PROJECT_ID]", "[LOCATION_ID]", "[MODEL_ID]"), DisplayName = "display_name137f65c2", DatasetId = "dataset_id08d366d3", CreateTime = new wkt::Timestamp(), DeploymentState = Model.Types.DeploymentState.Deployed, Etag = "etage8ad7218", UpdateTime = new wkt::Timestamp(), ImageClassificationModelMetadata = new ImageClassificationModelMetadata(), TextClassificationModelMetadata = new TextClassificationModelMetadata(), TranslationModelMetadata = new TranslationModelMetadata(), TextExtractionModelMetadata = new TextExtractionModelMetadata(), ImageObjectDetectionModelMetadata = new ImageObjectDetectionModelMetadata(), TextSentimentModelMetadata = new TextSentimentModelMetadata(), Labels = { { "key8a0b6e3c", "value60c16320" }, }, }; mockGrpcClient.Setup(x => x.GetModel(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse); AutoMlClient client = new AutoMlClientImpl(mockGrpcClient.Object, null); Model response = client.GetModel(request); xunit::Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }