public void TraceFunction() { var list = new System.Collections.Generic.List <string>(); using (NHunspellWrapper wrap = new NHunspellWrapper()) { wrap.LogAction = (x, y) => { if (x == typeof(MockSpeller)) { list.Add(y); } }; wrap.OverrideType = typeof(MockSpeller).AssemblyQualifiedName; wrap.Load(this.affixFile, this.dictFile); wrap.Spell("test"); wrap.Add("test"); } Assert.AreEqual(4, list.Count, string.Join(Environment.NewLine, list.ToArray())); Assert.IsTrue(list.Contains("Init")); Assert.IsTrue(list.Contains("Spell")); Assert.IsTrue(list.Contains("Add")); Assert.IsTrue(list.Contains("Free")); }
public void LoadPost() { // Load after construction using (NHunspellWrapper wrap = new NHunspellWrapper()) { wrap.OverrideType = typeof(MockSpeller).AssemblyQualifiedName; wrap.Load(this.affixFile, this.dictFile); Test(wrap); } }
public void InvalidType() { // Invalid type using (NHunspellWrapper wrap = new NHunspellWrapper()) { wrap.OverrideType = "failure.type"; try { wrap.Load(this.affixFile, this.dictFile); Test(wrap); } catch (ArgumentException argExp) { if (!argExp.Message.Contains("Invalid Hunspell instance type")) { throw; } } } }
/// <summary> /// The entry-point class for this application. /// </summary> /// <param name='args'>Command-line arguments</param> public static void Main(string[] args) { bool error = false; if (args == null || args.Length != 2) { Console.WriteLine("Arguments for testing not sent. The arguments are full paths to the aff and dict files (in that order)"); error = true; } else { try { // Load on construction using (NHunspellWrapper wrap = new NHunspellWrapper(args[0], args[1])) { Test(wrap); } // Load after construction using (NHunspellWrapper wrap = new NHunspellWrapper()) { wrap.Load(args[0], args[1]); Test(wrap); } // Never load using (NHunspellWrapper wrap = new NHunspellWrapper()) { try { Test(wrap); } catch (InvalidOperationException inv) { if (!inv.Message.Contains("Speller not initialized")) { throw; } } } // Invalid type using (NHunspellWrapper wrap = new NHunspellWrapper()) { wrap.OverrideType = "failure.type"; try { wrap.Load(args[0], args[1]); Test(wrap); } catch (ArgumentException argExp) { if (!argExp.Message.Contains("Invalid Hunspell instance type")) { throw; } } } } catch (Exception ex) { Console.WriteLine(ex); error = true; } } if (error) { System.Environment.Exit(1); } }
public void TraceFunction() { var list = new System.Collections.Generic.List<string>(); using (NHunspellWrapper wrap = new NHunspellWrapper()) { wrap.LogAction = (x, y) => { if (x == typeof(MockSpeller)) { list.Add(y); } }; wrap.OverrideType = typeof(MockSpeller).AssemblyQualifiedName; wrap.Load(this.affixFile, this.dictFile); wrap.Spell("test"); wrap.Add("test"); } Assert.AreEqual(4, list.Count, string.Join(Environment.NewLine, list.ToArray())); Assert.IsTrue(list.Contains("Init")); Assert.IsTrue(list.Contains("Spell")); Assert.IsTrue(list.Contains("Add")); Assert.IsTrue(list.Contains("Free")); }