1919
2020using Bandwidth . Standard . Client ;
2121using Bandwidth . Standard . Api ;
22- // uncomment below to import models
23- //using Bandwidth.Standard.Model;
22+ using Moq ;
23+ using System . Net ;
24+ using System . Data . SqlTypes ;
25+ using Bandwidth . Standard . Model ;
26+ using System . Security . Authentication ;
2427
2528namespace Bandwidth . Standard . Test . Api
2629{
@@ -34,10 +37,19 @@ namespace Bandwidth.Standard.Test.Api
3437 public class TranscriptionsApiTests : IDisposable
3538 {
3639 private TranscriptionsApi instance ;
40+ private Mock < ISynchronousClient > mockClient ;
41+ private Mock < IAsynchronousClient > mockAsynchronousClient ;
42+ private Configuration fakeConfiguration ;
3743
3844 public TranscriptionsApiTests ( )
3945 {
40- instance = new TranscriptionsApi ( ) ;
46+ mockClient = new Mock < ISynchronousClient > ( ) ;
47+ mockAsynchronousClient = new Mock < IAsynchronousClient > ( ) ;
48+ fakeConfiguration = new Configuration ( ) ;
49+ fakeConfiguration . BasePath = "https://voice.bandwidth.com/api/v2" ;
50+ fakeConfiguration . Username = "username" ;
51+ fakeConfiguration . Password = "password" ;
52+ instance = new TranscriptionsApi ( mockClient . Object , mockAsynchronousClient . Object , fakeConfiguration ) ;
4153 }
4254
4355 public void Dispose ( )
@@ -51,8 +63,7 @@ public void Dispose()
5163 [ Fact ]
5264 public void InstanceTest ( )
5365 {
54- // TODO uncomment below to test 'IsType' TranscriptionsApi
55- //Assert.IsType<TranscriptionsApi>(instance);
66+ Assert . IsType < TranscriptionsApi > ( instance ) ;
5667 }
5768
5869 /// <summary>
@@ -61,11 +72,16 @@ public void InstanceTest()
6172 [ Fact ]
6273 public void DeleteRealTimeTranscriptionTest ( )
6374 {
64- // TODO uncomment below to test the method and replace null with proper value
65- //string accountId = null;
66- //string callId = null;
67- //string transcriptionId = null;
68- //instance.DeleteRealTimeTranscription(accountId, callId, transcriptionId);
75+ string accountId = "9900000" ;
76+ string callId = "c-12345" ;
77+ string transcriptionId = "t-12345" ;
78+
79+ var apiResponse = new ApiResponse < Object > ( HttpStatusCode . NoContent , null ) ;
80+ mockClient . Setup ( x => x . Delete < Object > ( "/accounts/{accountId}/calls/{callId}/transcriptions/{transcriptionId}" , It . IsAny < RequestOptions > ( ) , fakeConfiguration ) ) . Returns ( apiResponse ) ;
81+ var response = instance . DeleteRealTimeTranscriptionWithHttpInfo ( accountId , callId , transcriptionId ) ;
82+
83+ Assert . IsType < ApiResponse < Object > > ( response ) ;
84+ Assert . Equal ( HttpStatusCode . NoContent , response . StatusCode ) ;
6985 }
7086
7187 /// <summary>
@@ -74,12 +90,24 @@ public void DeleteRealTimeTranscriptionTest()
7490 [ Fact ]
7591 public void GetRealTimeTranscriptionTest ( )
7692 {
77- // TODO uncomment below to test the method and replace null with proper value
78- //string accountId = null;
79- //string callId = null;
80- //string transcriptionId = null;
81- //var response = instance.GetRealTimeTranscription(accountId, callId, transcriptionId);
82- //Assert.IsType<CallTranscriptionResponse>(response);
93+ string accountId = "9900000" ;
94+ string callId = "c-12345" ;
95+ string transcriptionId = "t-12345" ;
96+
97+ CallTranscription . DetectedLanguageEnum detectedLanguage = CallTranscription . DetectedLanguageEnum . EnUS ;
98+ CallTranscription . TrackEnum track = CallTranscription . TrackEnum . Inbound ;
99+
100+ CallTranscription transcription = new CallTranscription ( detectedLanguage : detectedLanguage , track : track , transcript : "abc 123 this is a test" , confidence : 0.9 ) ;
101+
102+ List < CallTranscription > tracks = new List < CallTranscription > { transcription } ;
103+
104+ CallTranscriptionResponse callTranscriptionResponse = new CallTranscriptionResponse ( accountId : accountId , callId : callId , transcriptionId : transcriptionId , tracks : tracks ) ;
105+
106+ var apiResponse = new ApiResponse < CallTranscriptionResponse > ( HttpStatusCode . NoContent , callTranscriptionResponse ) ;
107+ mockClient . Setup ( x => x . Get < CallTranscriptionResponse > ( "/accounts/{accountId}/calls/{callId}/transcriptions/{transcriptionId}" , It . IsAny < RequestOptions > ( ) , fakeConfiguration ) ) . Returns ( apiResponse ) ;
108+ var response = instance . GetRealTimeTranscription ( accountId , callId , transcriptionId ) ;
109+
110+ Assert . IsType < CallTranscriptionResponse > ( response ) ;
83111 }
84112
85113 /// <summary>
@@ -88,11 +116,17 @@ public void GetRealTimeTranscriptionTest()
88116 [ Fact ]
89117 public void ListRealTimeTranscriptionsTest ( )
90118 {
91- // TODO uncomment below to test the method and replace null with proper value
92- //string accountId = null;
93- //string callId = null;
94- //var response = instance.ListRealTimeTranscriptions(accountId, callId);
95- //Assert.IsType<List<CallTranscriptionMetadata>>(response);
119+ string accountId = "9900000" ;
120+ string callId = "c-12345" ;
121+
122+ CallTranscriptionMetadata transcription = new CallTranscriptionMetadata ( transcriptionId : "t-12345" , transcriptionUrl : "https://voice.bandwidth.com/api/v2/accounts/9900000/calls/c-12345/transcriptions/t-12345" ) ;
123+ List < CallTranscriptionMetadata > callTranscriptions = new List < CallTranscriptionMetadata > { transcription } ;
124+
125+ var apiResponse = new ApiResponse < List < CallTranscriptionMetadata > > ( HttpStatusCode . NoContent , callTranscriptions ) ;
126+ mockClient . Setup ( x => x . Get < List < CallTranscriptionMetadata > > ( "/accounts/{accountId}/calls/{callId}/transcriptions" , It . IsAny < RequestOptions > ( ) , fakeConfiguration ) ) . Returns ( apiResponse ) ;
127+ var response = instance . ListRealTimeTranscriptions ( accountId , callId ) ;
128+
129+ Assert . IsType < List < CallTranscriptionMetadata > > ( response ) ;
96130 }
97131 }
98132}
0 commit comments