public void PcPatrInvokerFailureTest() { String grammarFile = Path.Combine(TestDataDir, "GrammarFail.grm"); String anaFile = Path.Combine(TestDataDir, "InvokerFail.ana"); var invoker = new PCPatrInvoker(grammarFile, anaFile, "Off"); invoker.Invoke(); Assert.AreEqual(false, invoker.InvocationSucceeded); }
public void PcPatrInvokerTest() { String grammarFile = Path.Combine(TestDataDir, "Invoker.grm"); String anaFile = Path.Combine(TestDataDir, "Invoker.ana"); String andFile = Path.Combine(TestDataDir, "InvokerB4.and"); using (var streamReader = new StreamReader(andFile, Encoding.UTF8)) { AndString = streamReader.ReadToEnd().Replace("\r", ""); } var invoker = new PCPatrInvoker(grammarFile, anaFile, "Off"); invoker.Invoke(); Assert.AreEqual(true, invoker.InvocationSucceeded); String andResult = ""; using (var streamReader = new StreamReader(invoker.AndFile, Encoding.UTF8)) { andResult = streamReader.ReadToEnd().Replace("\r", ""); } // The \id line has the location of the Invoker.grm file which will vary by machine. // So we just check the firset 23 characters (which are always the same) // and what starts at "Invoker.grm". int iIDBeginning = 23; int iExpected = AndString.IndexOf("Invoker.grm"); int iResult = andResult.IndexOf("Invoker.grm"); Assert.AreEqual(AndString.Substring(0, iIDBeginning), andResult.Substring(0, iIDBeginning)); Assert.AreEqual(AndString.Substring(iExpected), andResult.Substring(iResult)); checkRootGlossState(invoker, null); checkRootGlossState(invoker, "off"); checkRootGlossState(invoker, "leftheaded"); checkRootGlossState(invoker, "rightheaded"); checkRootGlossState(invoker, "all"); checkRootGlossStateValue(invoker, null, null); checkRootGlossStateValue(invoker, "Off", "off"); checkRootGlossStateValue(invoker, "Leftheaded", "leftheaded"); checkRootGlossStateValue(invoker, "Rightheaded", "rightheaded"); checkRootGlossStateValue(invoker, "All", "all"); checkRootGlossStateValue(invoker, "Of course", "off"); checkRootGlossStateValue(invoker, "Luis", "leftheaded"); checkRootGlossStateValue(invoker, "Rival", "rightheaded"); checkRootGlossStateValue(invoker, "Alone", "all"); }
private void checkRootGlossState(PCPatrInvoker invoker, string state) { String takeFile = Path.Combine(Path.GetTempPath(), "PcPatrFLEx.tak"); invoker.RootGlossState = state; invoker.Invoke(); using (var streamReader = new StreamReader(takeFile, Encoding.UTF8)) { TakeString = streamReader.ReadToEnd().Replace("\r", ""); } if (String.IsNullOrEmpty(state)) { Assert.IsFalse(TakeString.Contains("set rootgloss ")); } else { Assert.IsTrue(TakeString.Contains("set rootgloss " + state + "\n")); } }