public async Task SynthesizeSpeechAsync() { Mock <TextToSpeech.TextToSpeechClient> mockGrpcClient = new Mock <TextToSpeech.TextToSpeechClient>(MockBehavior.Strict); SynthesizeSpeechRequest expectedRequest = new SynthesizeSpeechRequest { Input = new SynthesisInput(), Voice = new VoiceSelectionParams(), AudioConfig = new AudioConfig(), }; SynthesizeSpeechResponse expectedResponse = new SynthesizeSpeechResponse { AudioContent = ByteString.CopyFromUtf8("16"), }; mockGrpcClient.Setup(x => x.SynthesizeSpeechAsync(expectedRequest, It.IsAny <CallOptions>())) .Returns(new Grpc.Core.AsyncUnaryCall <SynthesizeSpeechResponse>(Task.FromResult(expectedResponse), null, null, null, null)); TextToSpeechClient client = new TextToSpeechClientImpl(mockGrpcClient.Object, null); SynthesisInput input = new SynthesisInput(); VoiceSelectionParams voice = new VoiceSelectionParams(); AudioConfig audioConfig = new AudioConfig(); SynthesizeSpeechResponse response = await client.SynthesizeSpeechAsync(input, voice, audioConfig); Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }
public async stt::Task SynthesizeSpeechAsync() { moq::Mock <TextToSpeech.TextToSpeechClient> mockGrpcClient = new moq::Mock <TextToSpeech.TextToSpeechClient>(moq::MockBehavior.Strict); SynthesizeSpeechRequest request = new SynthesizeSpeechRequest { Input = new SynthesisInput(), Voice = new VoiceSelectionParams(), AudioConfig = new AudioConfig(), }; SynthesizeSpeechResponse expectedResponse = new SynthesizeSpeechResponse { AudioContent = proto::ByteString.CopyFromUtf8("audio_content20992f23"), Timepoints = { new Timepoint(), }, AudioConfig = new AudioConfig(), }; mockGrpcClient.Setup(x => x.SynthesizeSpeechAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <SynthesizeSpeechResponse>(stt::Task.FromResult(expectedResponse), null, null, null, null)); TextToSpeechClient client = new TextToSpeechClientImpl(mockGrpcClient.Object, null); SynthesizeSpeechResponse responseCallSettings = await client.SynthesizeSpeechAsync(request.Input, request.Voice, request.AudioConfig, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None)); xunit::Assert.Same(expectedResponse, responseCallSettings); SynthesizeSpeechResponse responseCancellationToken = await client.SynthesizeSpeechAsync(request.Input, request.Voice, request.AudioConfig, st::CancellationToken.None); xunit::Assert.Same(expectedResponse, responseCancellationToken); mockGrpcClient.VerifyAll(); }
public void SynthesizeSpeechRequestObject() { moq::Mock <TextToSpeech.TextToSpeechClient> mockGrpcClient = new moq::Mock <TextToSpeech.TextToSpeechClient>(moq::MockBehavior.Strict); SynthesizeSpeechRequest request = new SynthesizeSpeechRequest { Input = new SynthesisInput(), Voice = new VoiceSelectionParams(), AudioConfig = new AudioConfig(), EnableTimePointing = { SynthesizeSpeechRequest.Types.TimepointType.Unspecified, }, }; SynthesizeSpeechResponse expectedResponse = new SynthesizeSpeechResponse { AudioContent = proto::ByteString.CopyFromUtf8("audio_content20992f23"), Timepoints = { new Timepoint(), }, AudioConfig = new AudioConfig(), }; mockGrpcClient.Setup(x => x.SynthesizeSpeech(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse); TextToSpeechClient client = new TextToSpeechClientImpl(mockGrpcClient.Object, null); SynthesizeSpeechResponse response = client.SynthesizeSpeech(request); xunit::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(); }
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 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 void SynthesizeSpeech2() { Mock <TextToSpeech.TextToSpeechClient> mockGrpcClient = new Mock <TextToSpeech.TextToSpeechClient>(MockBehavior.Strict); SynthesizeSpeechRequest request = new SynthesizeSpeechRequest { Input = new SynthesisInput(), Voice = new VoiceSelectionParams(), AudioConfig = new AudioConfig(), }; SynthesizeSpeechResponse expectedResponse = new SynthesizeSpeechResponse { AudioContent = ByteString.CopyFromUtf8("16"), }; mockGrpcClient.Setup(x => x.SynthesizeSpeech(request, It.IsAny <CallOptions>())) .Returns(expectedResponse); TextToSpeechClient client = new TextToSpeechClientImpl(mockGrpcClient.Object, null); SynthesizeSpeechResponse response = client.SynthesizeSpeech(request); 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(); }