From 11957a77994389752a02bb61c67f4c40c7a33875 Mon Sep 17 00:00:00 2001 From: Alexander Radchenko Date: Thu, 23 Sep 2021 13:49:55 +0700 Subject: [PATCH 1/2] Add checking SpeechRecognitionEngine Culture to GrammarBuilder test. --- src/libraries/System.Speech/tests/GrammarTests.cs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/libraries/System.Speech/tests/GrammarTests.cs b/src/libraries/System.Speech/tests/GrammarTests.cs index f891ffa62e593..351cdc52e941f 100644 --- a/src/libraries/System.Speech/tests/GrammarTests.cs +++ b/src/libraries/System.Speech/tests/GrammarTests.cs @@ -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(() => rec.LoadGrammar(grammar)); + } } } From 2af3d3b6d0cee444f44c26725956e4459ebde804 Mon Sep 17 00:00:00 2001 From: Dan Moseley Date: Fri, 24 Sep 2021 19:25:49 -0600 Subject: [PATCH 2/2] Update GrammarTests.cs --- src/libraries/System.Speech/tests/GrammarTests.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/libraries/System.Speech/tests/GrammarTests.cs b/src/libraries/System.Speech/tests/GrammarTests.cs index 351cdc52e941f..8c0522757332f 100644 --- a/src/libraries/System.Speech/tests/GrammarTests.cs +++ b/src/libraries/System.Speech/tests/GrammarTests.cs @@ -124,7 +124,8 @@ public void GrammarBuilder() } else { - Assert.Throws(() => rec.LoadGrammar(grammar)); + // Sometimes throws and sometimes does not + // Assert.Throws(() => rec.LoadGrammar(grammar)); } } }