Skip to content

Commit fa80207

Browse files
ATILATostaATILATosta
authored andcommitted
fixed: ObserveResult_Success unit test method
fixed: ObserveResult_Catch_Exception unit test method
1 parent 5b475ce commit fa80207

File tree

1 file changed

+5
-59
lines changed

1 file changed

+5
-59
lines changed

test/IBM.WatsonDeveloperCloud.SpeechToText.UnitTests/SpeechToTextServiceUnitTest.cs

Lines changed: 5 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1373,69 +1373,15 @@ public void ObserveResult_Success()
13731373
client.WithAuthentication(Arg.Any<string>(), Arg.Any<string>())
13741374
.Returns(client);
13751375

1376-
SpeechRecognitionEvent response = new SpeechRecognitionEvent()
1377-
{
1378-
ResultIndex = 1,
1379-
Results = new List<SpeechRecognitionResult>()
1380-
{
1381-
new SpeechRecognitionResult()
1382-
{
1383-
Alternatives = new List<SpeechRecognitionAlternative>()
1384-
{
1385-
new SpeechRecognitionAlternative()
1386-
{
1387-
Confidence = 0.9,
1388-
Timestamps = new List<string>(),
1389-
Transcript = "transcript",
1390-
WordConfidence = new List<string>()
1391-
}
1392-
},
1393-
Final = true,
1394-
KeywordResults = new KeywordResults()
1395-
{
1396-
Keyword = new List<KeywordResult>()
1397-
{
1398-
new KeywordResult()
1399-
{
1400-
Confidence = 0.9,
1401-
Endtime = 0.1,
1402-
NormalizedText = "normalized_text",
1403-
StartTime = 0
1404-
}
1405-
}
1406-
},
1407-
WordAlternativeResults = new List<WordAlternativeResults>()
1408-
{
1409-
new WordAlternativeResults()
1410-
{
1411-
Alternatives = new List<WordAlternativeResult>()
1412-
{
1413-
new WordAlternativeResult()
1414-
{
1415-
Confidence = 0.9,
1416-
Word = 0.1
1417-
}
1418-
},
1419-
Endtime = 1,
1420-
StartTime = 0.1
1421-
}
1422-
}
1423-
}
1424-
}
1425-
};
1426-
14271376
IRequest request = Substitute.For<IRequest>();
1428-
client.PostAsync(Arg.Any<string>())
1377+
client.GetAsync(Arg.Any<string>())
14291378
.Returns(request);
14301379

14311380
request.WithArgument(Arg.Any<string>(), Arg.Any<object>())
14321381
.Returns(request);
14331382

1434-
request.AsList<SpeechRecognitionEvent>()
1435-
.Returns(Task.FromResult(new List<SpeechRecognitionEvent>()
1436-
{
1437-
response
1438-
}));
1383+
request.AsString()
1384+
.Returns(Task.FromResult("{\"results\":[{\"alternatives\":[{\"transcript\":\"several torn \"}],\"final\":false}],\"result_index\":0}"));
14391385

14401386
#endregion
14411387

@@ -1444,7 +1390,7 @@ public void ObserveResult_Success()
14441390
var recognitionEvent = service.ObserveResult("session_id", 1, true);
14451391

14461392
Assert.IsNotNull(recognitionEvent);
1447-
client.Received().PostAsync(Arg.Any<string>());
1393+
client.Received().GetAsync(Arg.Any<string>());
14481394
Assert.IsTrue(recognitionEvent.Count > 0);
14491395
}
14501396

@@ -1490,7 +1436,7 @@ public void ObserveResult_Catch_Exception()
14901436
SpeechRecognitionEvent response = new SpeechRecognitionEvent();
14911437

14921438
IRequest request = Substitute.For<IRequest>();
1493-
client.PostAsync(Arg.Any<string>())
1439+
client.GetAsync(Arg.Any<string>())
14941440
.Returns(x =>
14951441
{
14961442
throw new AggregateException(new ServiceResponseException(Substitute.For<IResponse>(),

0 commit comments

Comments
 (0)