public void ListVoices2() { Mock <TextToSpeech.TextToSpeechClient> mockGrpcClient = new Mock <TextToSpeech.TextToSpeechClient>(MockBehavior.Strict); ListVoicesRequest request = new ListVoicesRequest(); ListVoicesResponse expectedResponse = new ListVoicesResponse(); mockGrpcClient.Setup(x => x.ListVoices(request, It.IsAny <CallOptions>())) .Returns(expectedResponse); TextToSpeechClient client = new TextToSpeechClientImpl(mockGrpcClient.Object, null); ListVoicesResponse response = client.ListVoices(request); Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }
public async Task ListVoicesAsync2() { Mock <TextToSpeech.TextToSpeechClient> mockGrpcClient = new Mock <TextToSpeech.TextToSpeechClient>(MockBehavior.Strict); ListVoicesRequest request = new ListVoicesRequest(); ListVoicesResponse expectedResponse = new ListVoicesResponse(); mockGrpcClient.Setup(x => x.ListVoicesAsync(request, It.IsAny <CallOptions>())) .Returns(new Grpc.Core.AsyncUnaryCall <ListVoicesResponse>(Task.FromResult(expectedResponse), null, null, null, null)); TextToSpeechClient client = new TextToSpeechClientImpl(mockGrpcClient.Object, null); ListVoicesResponse response = await client.ListVoicesAsync(request); Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }
/// <summary>Snippet for ListVoicesAsync</summary> public async Task ListVoicesAsync() { // Snippet: ListVoicesAsync(string, CallSettings) // Additional: ListVoicesAsync(string, CancellationToken) // Create client TextToSpeechClient textToSpeechClient = await TextToSpeechClient.CreateAsync(); // Initialize request argument(s) string languageCode = ""; // Make the request ListVoicesResponse response = await textToSpeechClient.ListVoicesAsync(languageCode); // End snippet }
/// <summary>Snippet for ListVoicesAsync</summary> public async Task ListVoicesAsync_RequestObject() { // Snippet: ListVoicesAsync(ListVoicesRequest,CallSettings) // Additional: ListVoicesAsync(ListVoicesRequest,CancellationToken) // Create client TextToSpeechClient textToSpeechClient = await TextToSpeechClient.CreateAsync(); // Initialize request argument(s) ListVoicesRequest request = new ListVoicesRequest(); // Make the request ListVoicesResponse response = await textToSpeechClient.ListVoicesAsync(request); // End snippet }
public void ListVoices() { Mock <TextToSpeech.TextToSpeechClient> mockGrpcClient = new Mock <TextToSpeech.TextToSpeechClient>(MockBehavior.Strict); ListVoicesRequest expectedRequest = new ListVoicesRequest { LanguageCode = "languageCode-412800396", }; ListVoicesResponse expectedResponse = new ListVoicesResponse(); mockGrpcClient.Setup(x => x.ListVoices(expectedRequest, It.IsAny <CallOptions>())) .Returns(expectedResponse); TextToSpeechClient client = new TextToSpeechClientImpl(mockGrpcClient.Object, null); string languageCode = "languageCode-412800396"; ListVoicesResponse response = client.ListVoices(languageCode); Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }
public void ListVoices() { moq::Mock <TextToSpeech.TextToSpeechClient> mockGrpcClient = new moq::Mock <TextToSpeech.TextToSpeechClient>(moq::MockBehavior.Strict); ListVoicesRequest request = new ListVoicesRequest { LanguageCode = "language_code2f6c7160", }; ListVoicesResponse expectedResponse = new ListVoicesResponse { Voices = { new Voice(), }, }; mockGrpcClient.Setup(x => x.ListVoices(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse); TextToSpeechClient client = new TextToSpeechClientImpl(mockGrpcClient.Object, null); ListVoicesResponse response = client.ListVoices(request.LanguageCode); xunit::Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }
public async stt::Task ListVoicesAsync() { moq::Mock <TextToSpeech.TextToSpeechClient> mockGrpcClient = new moq::Mock <TextToSpeech.TextToSpeechClient>(moq::MockBehavior.Strict); ListVoicesRequest request = new ListVoicesRequest { LanguageCode = "language_code2f6c7160", }; ListVoicesResponse expectedResponse = new ListVoicesResponse { Voices = { new Voice(), }, }; mockGrpcClient.Setup(x => x.ListVoicesAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <ListVoicesResponse>(stt::Task.FromResult(expectedResponse), null, null, null, null)); TextToSpeechClient client = new TextToSpeechClientImpl(mockGrpcClient.Object, null); ListVoicesResponse responseCallSettings = await client.ListVoicesAsync(request.LanguageCode, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None)); xunit::Assert.Same(expectedResponse, responseCallSettings); ListVoicesResponse responseCancellationToken = await client.ListVoicesAsync(request.LanguageCode, st::CancellationToken.None); xunit::Assert.Same(expectedResponse, responseCancellationToken); mockGrpcClient.VerifyAll(); }