public void Predict() { Mock <PredictionService.PredictionServiceClient> mockGrpcClient = new Mock <PredictionService.PredictionServiceClient>(MockBehavior.Strict); mockGrpcClient.Setup(x => x.CreateOperationsClient()) .Returns(new Mock <Operations.OperationsClient>().Object); PredictRequest expectedRequest = new PredictRequest { ModelName = new ModelName("[PROJECT]", "[LOCATION]", "[MODEL]"), Payload = new ExamplePayload(), Params = { }, }; PredictResponse expectedResponse = new PredictResponse(); mockGrpcClient.Setup(x => x.Predict(expectedRequest, It.IsAny <CallOptions>())) .Returns(expectedResponse); PredictionServiceClient client = new PredictionServiceClientImpl(mockGrpcClient.Object, null); ModelName name = new ModelName("[PROJECT]", "[LOCATION]", "[MODEL]"); ExamplePayload payload = new ExamplePayload(); IDictionary <string, string> @params = new Dictionary <string, string>(); PredictResponse response = client.Predict(name, payload, @params); Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }
public void PredictRequestObject() { moq::Mock <PredictionService.PredictionServiceClient> mockGrpcClient = new moq::Mock <PredictionService.PredictionServiceClient>(moq::MockBehavior.Strict); PredictRequest request = new PredictRequest { Placement = "placementb440552a", UserEvent = new UserEvent(), PageSize = -226905851, PageToken = "page_tokenf09e5538", Filter = "filtere47ac9b2", ValidateOnly = true, Params = { { "key8a0b6e3c", new wkt::Value() }, }, Labels = { { "key8a0b6e3c", "value60c16320" }, }, }; PredictResponse expectedResponse = new PredictResponse { Results = { new PredictResponse.Types.PredictionResult(), }, AttributionToken = "attribution_token14371a88", MissingIds = { "missing_ids9e3bd4de", }, ValidateOnly = true, }; mockGrpcClient.Setup(x => x.Predict(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse); PredictionServiceClient client = new PredictionServiceClientImpl(mockGrpcClient.Object, null); PredictResponse response = client.Predict(request); xunit::Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }
public void Predict2() { Mock <PredictionService.PredictionServiceClient> mockGrpcClient = new Mock <PredictionService.PredictionServiceClient>(MockBehavior.Strict); PredictRequest request = new PredictRequest { ModelName = new ModelName("[PROJECT]", "[LOCATION]", "[MODEL]"), Payload = new ExamplePayload(), }; PredictResponse expectedResponse = new PredictResponse(); mockGrpcClient.Setup(x => x.Predict(request, It.IsAny <CallOptions>())) .Returns(expectedResponse); PredictionServiceClient client = new PredictionServiceClientImpl(mockGrpcClient.Object, null); PredictResponse response = client.Predict(request); Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }
public void PredictRequestObject() { moq::Mock <PredictionService.PredictionServiceClient> mockGrpcClient = new moq::Mock <PredictionService.PredictionServiceClient>(moq::MockBehavior.Strict); mockGrpcClient.Setup(x => x.CreateOperationsClient()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object); PredictRequest request = new PredictRequest { ModelName = ModelName.FromProjectLocationModel("[PROJECT]", "[LOCATION]", "[MODEL]"), Payload = new ExamplePayload(), Params = { { "key8a0b6e3c", "value60c16320" }, }, }; PredictResponse expectedResponse = new PredictResponse { Payload = { new AnnotationPayload(), }, Metadata = { { "key8a0b6e3c", "value60c16320" }, }, PreprocessedInput = new ExamplePayload(), }; mockGrpcClient.Setup(x => x.Predict(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse); PredictionServiceClient client = new PredictionServiceClientImpl(mockGrpcClient.Object, null); PredictResponse response = client.Predict(request); xunit::Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }
public void Predict() { moq::Mock <PredictionService.PredictionServiceClient> mockGrpcClient = new moq::Mock <PredictionService.PredictionServiceClient>(moq::MockBehavior.Strict); PredictRequest request = new PredictRequest { EndpointAsEndpointName = EndpointName.FromProjectLocationEndpoint("[PROJECT]", "[LOCATION]", "[ENDPOINT]"), Instances = { new wkt::Value(), }, Parameters = new wkt::Value(), }; PredictResponse expectedResponse = new PredictResponse { Predictions = { new wkt::Value(), }, DeployedModelId = "deployed_model_idf0bd41af", }; mockGrpcClient.Setup(x => x.Predict(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse); PredictionServiceClient client = new PredictionServiceClientImpl(mockGrpcClient.Object, null); PredictResponse response = client.Predict(request.Endpoint, request.Instances, request.Parameters); xunit::Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }