public void Run_Help() { //todo: use moq to fake the console & state var console = new FakeCmdRConsole(""); var cmdR = new CmdR(new OrderedCommandParser(), new Routing(), new RouteParser(), console, new CmdRState()); cmdR.AutoRegisterCommands(); cmdR.RegisterRoute("cd", (p, con, state) => { state.CmdPrompt = "new prompt> "; }); cmdR.Run(new[] { "?" }); Assert.AreEqual("basic-module1 ", console.ConsoleWindow[0]); Assert.AreEqual("basic-module2 ", console.ConsoleWindow[1]); Assert.AreEqual("attribute-module1 ", console.ConsoleWindow[2]); Assert.AreEqual("attribute-module2 ", console.ConsoleWindow[3]); Assert.AreEqual("? ", console.ConsoleWindow[4]); Assert.AreEqual("cd ", console.ConsoleWindow[5]); Assert.AreEqual("", console.ConsoleWindow[6]); Assert.AreEqual("> ", console.ConsoleWindow[7]); Assert.AreEqual("> ", console.ConsoleWindow[8]); }
public void AutoRegisterCommands_AttributeCommandAreRegistered() { var cmdR = new CmdR("> "); cmdR.AutoRegisterCommands(); Assert.AreEqual(true, cmdR.State.Routes.Any(x => x.Name == "attribute-module1")); Assert.AreEqual(true, cmdR.State.Routes.Any(x => x.Name == "attribute-module2")); }
public void AutoRegisterCommands_LoadsUpBothModulesAndAllCommandsAreRegistered() { var cmdR = new CmdR("> "); cmdR.AutoRegisterCommands(); // 1 built in route, 2 basic module commands, 2 attribute commands Assert.AreEqual(5, cmdR.State.Routes.Count); }
public void AutoRegisterCommands_AttributeCommandAreRegistered() { var cmdR = new CmdR("> "); cmdR.AutoRegisterCommands(); Assert.AreEqual(true, cmdR.State.Routes.Any(x => x.Name == "attribute-module1")); Assert.AreEqual(true, cmdR.State.Routes.Any(x => x.Name == "attribute-module2")); }
public void AutoRegisterCommands_LoadsUpBothModulesAndAllCommandsAreRegistered() { var cmdR = new CmdR("> "); cmdR.AutoRegisterCommands(); // 1 built in route, 2 basic module commands, 2 attribute commands Assert.AreEqual(5, cmdR.State.Routes.Count); }
public void AutoRegisterCommands_CanInvokeAttributeModuleRouteOne() { var fakeConsole = new FakeCmdRConsole(""); var cmdR = new CmdR(console: fakeConsole); cmdR.AutoRegisterCommands(); cmdR.Run(new string[] { "attribute-module1" }); Assert.AreEqual("attribute-test1", fakeConsole.ConsoleWindow[0]); }
public void AutoRegisterCommands_CanInvokeBasicModuleRouteTwo() { var fakeConsole = new FakeCmdRConsole(""); var cmdR = new CmdR(console: fakeConsole); cmdR.AutoRegisterCommands(); cmdR.Run(new string[] { "basic-module2" }); Assert.AreEqual("module-test2", fakeConsole.ConsoleWindow[0]); }
static void Main(string[] args) { var cmdR = new CmdR("> ", new [] { "exit" }); cmdR.Console.WriteLine("Welcome to Midlands Bank Plc"); cmdR.Console.WriteLine("----------------------------"); cmdR.Console.WriteLine("type ? for help on available commands\n"); cmdR.AutoRegisterCommands(); cmdR.Run(args); }
public void AutoRegisterCommands_CanInvokeAttributeModuleRouteTwo() { var fakeConsole = new FakeCmdRConsole(""); var cmdR = new CmdR(console: fakeConsole); cmdR.AutoRegisterCommands(); cmdR.Run(new string[] { "attribute-module2" }); Assert.AreEqual("attribute-test2", fakeConsole.ConsoleWindow[0]); }
public void AutoRegisterCommands_CanInvokeBasicModuleRouteOne() { var fakeConsole = new FakeCmdRConsole(""); var cmdR = new CmdR(console: fakeConsole); cmdR.AutoRegisterCommands(); cmdR.Run(new string[] { "basic-module1" }); Assert.AreEqual("module-test1", fakeConsole.ConsoleWindow[0]); }
public void Run_HelpWithDetails() { //todo: use moq to fake the console & state var console = new FakeCmdRConsole(""); var cmdR = new CmdR(new OrderedCommandParser(), new Routing(), new RouteParser(), console, new CmdRState()); cmdR.AutoRegisterCommands(); cmdR.RegisterRoute("cd", (p, con, state) => { state.CmdPrompt = "new prompt> "; }, "changes directory"); cmdR.Run(new[] { "? cd" }); Assert.AreEqual(" cd", console.ConsoleWindow[0]); Assert.AreEqual(" changes directory", console.ConsoleWindow[1]); }
public void Run_HelpWithDetails() { //todo: use moq to fake the console & state var console = new FakeCmdRConsole(""); var cmdR = new CmdR(new OrderedCommandParser(), new Routing(), new RouteParser(), console, new CmdRState()); cmdR.AutoRegisterCommands(); cmdR.RegisterRoute("cd", (p, con, state) => { state.CmdPrompt = "new prompt> "; }, "changes directory"); cmdR.Run(new[] { "? cd" }); Assert.AreEqual(" cd", console.ConsoleWindow[0]); Assert.AreEqual(" changes directory", console.ConsoleWindow[1]); }
public void Run_Help() { //todo: use moq to fake the console & state var console = new FakeCmdRConsole(""); var cmdR = new CmdR(new OrderedCommandParser(), new Routing(), new RouteParser(), console, new CmdRState()); cmdR.AutoRegisterCommands(); cmdR.RegisterRoute("cd", (p, con, state) => { state.CmdPrompt = "new prompt> "; }); cmdR.Run(new[] { "?" }); Assert.AreEqual("basic-module1 ", console.ConsoleWindow[0]); Assert.AreEqual("basic-module2 ", console.ConsoleWindow[1]); Assert.AreEqual("attribute-module1 ", console.ConsoleWindow[2]); Assert.AreEqual("attribute-module2 ", console.ConsoleWindow[3]); Assert.AreEqual("? ", console.ConsoleWindow[4]); Assert.AreEqual("cd ", console.ConsoleWindow[5]); Assert.AreEqual("", console.ConsoleWindow[6]); Assert.AreEqual("> ", console.ConsoleWindow[7]); Assert.AreEqual("> ", console.ConsoleWindow[8]); }