public async stt::Task GetModelEvaluationRequestObjectAsync() { 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); GetModelEvaluationRequest request = new GetModelEvaluationRequest { Name = "name1c9368b0", }; ModelEvaluation expectedResponse = new ModelEvaluation { Name = "name1c9368b0", AnnotationSpecId = "annotation_spec_ide0c3e8b2", CreateTime = new wkt::Timestamp(), EvaluatedExampleCount = -1119926106, ClassificationEvaluationMetrics = new ClassificationEvaluationMetrics(), TranslationEvaluationMetrics = new TranslationEvaluationMetrics(), TextSentimentEvaluationMetrics = new TextSentimentEvaluationMetrics(), ImageObjectDetectionEvaluationMetrics = new ImageObjectDetectionEvaluationMetrics(), TextExtractionEvaluationMetrics = new TextExtractionEvaluationMetrics(), DisplayName = "display_name137f65c2", }; mockGrpcClient.Setup(x => x.GetModelEvaluationAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <ModelEvaluation>(stt::Task.FromResult(expectedResponse), null, null, null, null)); AutoMlClient client = new AutoMlClientImpl(mockGrpcClient.Object, null); ModelEvaluation responseCallSettings = await client.GetModelEvaluationAsync(request, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None)); xunit::Assert.Same(expectedResponse, responseCallSettings); ModelEvaluation responseCancellationToken = await client.GetModelEvaluationAsync(request, st::CancellationToken.None); xunit::Assert.Same(expectedResponse, responseCancellationToken); mockGrpcClient.VerifyAll(); }
public async Task GetModelEvaluationAsync2() { Mock <AutoMl.AutoMlClient> mockGrpcClient = new Mock <AutoMl.AutoMlClient>(MockBehavior.Strict); mockGrpcClient.Setup(x => x.CreateOperationsClient()) .Returns(new Mock <Operations.OperationsClient>().Object); GetModelEvaluationRequest request = new GetModelEvaluationRequest { ModelEvaluationName = new ModelEvaluationName("[PROJECT]", "[LOCATION]", "[MODEL]", "[MODEL_EVALUATION]"), }; ModelEvaluation expectedResponse = new ModelEvaluation { Name = "name2-1052831874", AnnotationSpecId = "annotationSpecId60690191", DisplayName = "displayName1615086568", EvaluatedExampleCount = 277565350, }; mockGrpcClient.Setup(x => x.GetModelEvaluationAsync(request, It.IsAny <CallOptions>())) .Returns(new Grpc.Core.AsyncUnaryCall <ModelEvaluation>(Task.FromResult(expectedResponse), null, null, null, null)); AutoMlClient client = new AutoMlClientImpl(mockGrpcClient.Object, null); ModelEvaluation response = await client.GetModelEvaluationAsync(request); Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }