Skip to content

Commit

Permalink
Add checking SpeechRecognitionEngine Culture to GrammarBuilder test (#…
Browse files Browse the repository at this point in the history
…59516)

* Add checking SpeechRecognitionEngine Culture to GrammarBuilder test.

* Update GrammarTests.cs

Co-authored-by: Dan Moseley <danmose@microsoft.com>
  • Loading branch information
AlexRadch and danmoseley authored Sep 27, 2021
1 parent 51e4954 commit 0d05e3e
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/libraries/System.Speech/tests/GrammarTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -112,12 +112,21 @@ public void GrammarBuilder()
setPhrase.Append(colorElement);

Choices bothChoices = new Choices(new GrammarBuilder[] { makePhrase, setPhrase });
Grammar grammar = new Grammar((GrammarBuilder)bothChoices);
GrammarBuilder builder = (GrammarBuilder)bothChoices;
Grammar grammar = new Grammar(builder);
grammar.Name = "backgroundColor";

using (var rec = new SpeechRecognitionEngine())
{
rec.LoadGrammar(grammar);
if (rec.RecognizerInfo.Culture == builder.Culture)
{
rec.LoadGrammar(grammar);
}
else
{
// Sometimes throws and sometimes does not
// Assert.Throws<InvalidOperationException>(() => rec.LoadGrammar(grammar));
}
}
}

Expand Down

0 comments on commit 0d05e3e

Please sign in to comment.