Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add checking SpeechRecognitionEngine Culture to GrammarBuilder test #59516

Merged
merged 2 commits into from
Sep 27, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 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,20 @@ 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
{
Assert.Throws<InvalidOperationException>(() => rec.LoadGrammar(grammar));
}
}
}

Expand Down