Parameters
- command
Library/Library.Test/TestCmdInterpreter.cs
C# | Copy Code |
---|---|
CommandInterpreter ci = new CommandInterpreter(DefaultCommands.None, new TestCommands()); Assert.AreEqual(2, ci.Options.Length); Assert.AreEqual("Other", ci.Options[0].DisplayName); Assert.AreEqual("SomeData", ci.Options[1].DisplayName); Assert.AreEqual(4, ci.Commands.Length); Assert.AreEqual("BlowUp", ci.Commands[0].DisplayName); Assert.AreEqual("Count", ci.Commands[1].DisplayName); // <= alpha-sorted Assert.AreEqual("ForXtoYbyZ", ci.Commands[2].DisplayName); Assert.AreEqual("Hidden", ci.Commands[3].DisplayName); foreach (ICommand c in ci.Commands) ci.RemoveCommand(c); Assert.AreEqual(0, ci.Commands.Length); ci = new CommandInterpreter(DefaultCommands.None); Assert.AreEqual(0, ci.Options.Length); Assert.AreEqual(0, ci.Commands.Length); ci.AddHandler(typeof(StaticTestFilter)); Assert.AreEqual(0, ci.Options.Length); // the type StaticTestFilter contains filters and no commands/options Assert.AreEqual(0, ci.Commands.Length); ci.AddHandler(new TestCommands()); Assert.AreEqual(2, ci.Options.Length); Assert.AreEqual(4, ci.Commands.Length); |
VB.NET | Copy Code |
---|---|
Dim ci As New CommandInterpreter(DefaultCommands.None, New TestCommands()) Assert.AreEqual(2, ci.Options.Length) Assert.AreEqual("Other", ci.Options(0).DisplayName) Assert.AreEqual("SomeData", ci.Options(1).DisplayName) Assert.AreEqual(4, ci.Commands.Length) Assert.AreEqual("BlowUp", ci.Commands(0).DisplayName) Assert.AreEqual("Count", ci.Commands(1).DisplayName) ' <= alpha-sorted Assert.AreEqual("ForXtoYbyZ", ci.Commands(2).DisplayName) Assert.AreEqual("Hidden", ci.Commands(3).DisplayName) For Each c As ICommand In ci.Commands ci.RemoveCommand(c) Next Assert.AreEqual(0, ci.Commands.Length) ci = New CommandInterpreter(DefaultCommands.None) Assert.AreEqual(0, ci.Options.Length) Assert.AreEqual(0, ci.Commands.Length) ci.[AddHandler](GetType(StaticTestFilter)) Assert.AreEqual(0, ci.Options.Length) ' the type StaticTestFilter contains filters and no commands/options Assert.AreEqual(0, ci.Commands.Length) ci.[AddHandler](New TestCommands()) Assert.AreEqual(2, ci.Options.Length) Assert.AreEqual(4, ci.Commands.Length) |
Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7