public async stt::Task FulfillIntentRequestObjectAsync() { moq::Mock <Sessions.SessionsClient> mockGrpcClient = new moq::Mock <Sessions.SessionsClient>(moq::MockBehavior.Strict); FulfillIntentRequest request = new FulfillIntentRequest { MatchIntentRequest = new MatchIntentRequest(), Match = new Match(), OutputAudioConfig = new OutputAudioConfig(), }; FulfillIntentResponse expectedResponse = new FulfillIntentResponse { ResponseId = "response_id17f822e1", QueryResult = new QueryResult(), OutputAudio = proto::ByteString.CopyFromUtf8("output_audio7e712c4b"), OutputAudioConfig = new OutputAudioConfig(), }; mockGrpcClient.Setup(x => x.FulfillIntentAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <FulfillIntentResponse>(stt::Task.FromResult(expectedResponse), null, null, null, null)); SessionsClient client = new SessionsClientImpl(mockGrpcClient.Object, null); FulfillIntentResponse responseCallSettings = await client.FulfillIntentAsync(request, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None)); xunit::Assert.Same(expectedResponse, responseCallSettings); FulfillIntentResponse responseCancellationToken = await client.FulfillIntentAsync(request, st::CancellationToken.None); xunit::Assert.Same(expectedResponse, responseCancellationToken); mockGrpcClient.VerifyAll(); }
/// <summary>Snippet for FulfillIntent</summary> public void FulfillIntentRequestObject() { // Snippet: FulfillIntent(FulfillIntentRequest, CallSettings) // Create client SessionsClient sessionsClient = SessionsClient.Create(); // Initialize request argument(s) FulfillIntentRequest request = new FulfillIntentRequest { MatchIntentRequest = new MatchIntentRequest(), Match = new Match(), OutputAudioConfig = new OutputAudioConfig(), }; // Make the request FulfillIntentResponse response = sessionsClient.FulfillIntent(request); // End snippet }
/// <summary>Snippet for FulfillIntentAsync</summary> public async Task FulfillIntentRequestObjectAsync() { // Snippet: FulfillIntentAsync(FulfillIntentRequest, CallSettings) // Additional: FulfillIntentAsync(FulfillIntentRequest, CancellationToken) // Create client SessionsClient sessionsClient = await SessionsClient.CreateAsync(); // Initialize request argument(s) FulfillIntentRequest request = new FulfillIntentRequest { MatchIntentRequest = new MatchIntentRequest(), Match = new Match(), OutputAudioConfig = new OutputAudioConfig(), }; // Make the request FulfillIntentResponse response = await sessionsClient.FulfillIntentAsync(request); // End snippet }
public void FulfillIntentRequestObject() { moq::Mock <Sessions.SessionsClient> mockGrpcClient = new moq::Mock <Sessions.SessionsClient>(moq::MockBehavior.Strict); FulfillIntentRequest request = new FulfillIntentRequest { MatchIntentRequest = new MatchIntentRequest(), Match = new Match(), OutputAudioConfig = new OutputAudioConfig(), }; FulfillIntentResponse expectedResponse = new FulfillIntentResponse { ResponseId = "response_id17f822e1", QueryResult = new QueryResult(), OutputAudio = proto::ByteString.CopyFromUtf8("output_audio7e712c4b"), OutputAudioConfig = new OutputAudioConfig(), }; mockGrpcClient.Setup(x => x.FulfillIntent(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse); SessionsClient client = new SessionsClientImpl(mockGrpcClient.Object, null); FulfillIntentResponse response = client.FulfillIntent(request); xunit::Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }