public void MatchIntentRequestObject() { moq::Mock <Sessions.SessionsClient> mockGrpcClient = new moq::Mock <Sessions.SessionsClient>(moq::MockBehavior.Strict); MatchIntentRequest request = new MatchIntentRequest { SessionAsSessionName = SessionName.FromProjectLocationAgentSession("[PROJECT]", "[LOCATION]", "[AGENT]", "[SESSION]"), QueryParams = new QueryParameters(), QueryInput = new QueryInput(), }; MatchIntentResponse expectedResponse = new MatchIntentResponse { Text = "textec51b21c", TriggerIntentAsIntentName = IntentName.FromProjectLocationAgentIntent("[PROJECT]", "[LOCATION]", "[AGENT]", "[INTENT]"), Transcript = "transcript20c5b28b", Matches = { new Match(), }, CurrentPage = new Page(), TriggerEvent = "trigger_eventff063b42", }; mockGrpcClient.Setup(x => x.MatchIntent(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse); SessionsClient client = new SessionsClientImpl(mockGrpcClient.Object, null); MatchIntentResponse response = client.MatchIntent(request); xunit::Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }
public async stt::Task MatchIntentRequestObjectAsync() { moq::Mock <Sessions.SessionsClient> mockGrpcClient = new moq::Mock <Sessions.SessionsClient>(moq::MockBehavior.Strict); MatchIntentRequest request = new MatchIntentRequest { SessionAsSessionName = SessionName.FromProjectLocationAgentSession("[PROJECT]", "[LOCATION]", "[AGENT]", "[SESSION]"), QueryParams = new QueryParameters(), QueryInput = new QueryInput(), }; MatchIntentResponse expectedResponse = new MatchIntentResponse { Text = "textec51b21c", TriggerIntentAsIntentName = IntentName.FromProjectLocationAgentIntent("[PROJECT]", "[LOCATION]", "[AGENT]", "[INTENT]"), Transcript = "transcript20c5b28b", Matches = { new Match(), }, CurrentPage = new Page(), TriggerEvent = "trigger_eventff063b42", }; mockGrpcClient.Setup(x => x.MatchIntentAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <MatchIntentResponse>(stt::Task.FromResult(expectedResponse), null, null, null, null)); SessionsClient client = new SessionsClientImpl(mockGrpcClient.Object, null); MatchIntentResponse responseCallSettings = await client.MatchIntentAsync(request, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None)); xunit::Assert.Same(expectedResponse, responseCallSettings); MatchIntentResponse responseCancellationToken = await client.MatchIntentAsync(request, st::CancellationToken.None); xunit::Assert.Same(expectedResponse, responseCancellationToken); mockGrpcClient.VerifyAll(); }
/// <summary>Snippet for MatchIntent</summary> public void MatchIntentRequestObject() { // Snippet: MatchIntent(MatchIntentRequest, CallSettings) // Create client SessionsClient sessionsClient = SessionsClient.Create(); // Initialize request argument(s) MatchIntentRequest request = new MatchIntentRequest { SessionAsSessionName = SessionName.FromProjectLocationAgentSession("[PROJECT]", "[LOCATION]", "[AGENT]", "[SESSION]"), QueryParams = new QueryParameters(), QueryInput = new QueryInput(), }; // Make the request MatchIntentResponse response = sessionsClient.MatchIntent(request); // End snippet }
/// <summary>Snippet for MatchIntentAsync</summary> public async Task MatchIntentRequestObjectAsync() { // Snippet: MatchIntentAsync(MatchIntentRequest, CallSettings) // Additional: MatchIntentAsync(MatchIntentRequest, CancellationToken) // Create client SessionsClient sessionsClient = await SessionsClient.CreateAsync(); // Initialize request argument(s) MatchIntentRequest request = new MatchIntentRequest { SessionAsSessionName = SessionName.FromProjectLocationAgentSession("[PROJECT]", "[LOCATION]", "[AGENT]", "[SESSION]"), QueryParams = new QueryParameters(), QueryInput = new QueryInput(), }; // Make the request MatchIntentResponse response = await sessionsClient.MatchIntentAsync(request); // End snippet }