public void GetIntent() { Mock <Intents.IntentsClient> mockGrpcClient = new Mock <Intents.IntentsClient>(MockBehavior.Strict); mockGrpcClient.Setup(x => x.CreateOperationsClient()) .Returns(new Mock <Operations.OperationsClient>().Object); GetIntentRequest expectedRequest = new GetIntentRequest { IntentName = new IntentName("[PROJECT]", "[INTENT]"), }; Intent expectedResponse = new Intent { IntentName = new IntentName("[PROJECT]", "[INTENT]"), DisplayName = "displayName1615086568", Priority = 1165461084, IsFallback = false, MlDisabled = true, Action = "action-1422950858", ResetContexts = true, RootFollowupIntentName = "rootFollowupIntentName402253784", ParentFollowupIntentName = "parentFollowupIntentName-1131901680", }; mockGrpcClient.Setup(x => x.GetIntent(expectedRequest, It.IsAny <CallOptions>())) .Returns(expectedResponse); IntentsClient client = new IntentsClientImpl(mockGrpcClient.Object, null); IntentName name = new IntentName("[PROJECT]", "[INTENT]"); Intent response = client.GetIntent(name); Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }
public void GetIntentRequestObject() { moq::Mock <Intents.IntentsClient> mockGrpcClient = new moq::Mock <Intents.IntentsClient>(moq::MockBehavior.Strict); GetIntentRequest request = new GetIntentRequest { IntentName = IntentName.FromProjectLocationAgentIntent("[PROJECT]", "[LOCATION]", "[AGENT]", "[INTENT]"), LanguageCode = "language_code2f6c7160", }; Intent expectedResponse = new Intent { IntentName = IntentName.FromProjectLocationAgentIntent("[PROJECT]", "[LOCATION]", "[AGENT]", "[INTENT]"), DisplayName = "display_name137f65c2", TrainingPhrases = { new Intent.Types.TrainingPhrase(), }, Parameters = { new Intent.Types.Parameter(), }, Priority = 1546225849, IsFallback = true, Labels = { { "key8a0b6e3c", "value60c16320" }, }, Description = "description2cf9da67", }; mockGrpcClient.Setup(x => x.GetIntent(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse); IntentsClient client = new IntentsClientImpl(mockGrpcClient.Object, null); Intent response = client.GetIntent(request); xunit::Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }