public void TestExecution() { //Asserts that a command can be run and returns the expected result using (CommandRegistry registry = new CommandRegistry(new RegistrySettings())) { registry.AddCommand(typeof(TestCommand)); ManualResetEvent mre = new ManualResetEvent(false); object testOutput = null; registry.HandleInput("unit-test", null, (result, output) => { testOutput = output; mre.Set(); }); mre.WaitOne(); Assert.AreEqual(testOutput, CommandOutput); } }
public void TestScanner() { using (CommandRegistry registry = new CommandRegistry(new RegistrySettings())) { ManualResetEvent mre = new ManualResetEvent(false); object output = null; registry.AddScanner(@"Scanner \w+ \d+", (IContextObject ctx, string match, LightweightParser parser, ref bool finalize) => { output = ScannerOutput; mre.Set(); return(ScannerOutput); }); registry.HandleInput("Scanner pattern 123", null, null); mre.WaitOne(); Assert.AreEqual(output, ScannerOutput); } }