public void Constructor_Sets_Help_WhenEmpty() { var help = string.Empty; var gc = new GlobalCommand("TestTest", help, Access.Administrator); Assert.IsTrue(gc.Help == help); }
public void Constructor_Sets_Name() { var expected = "ex"; var gc = new GlobalCommand(expected, "help", Access.Administrator); Assert.IsTrue(gc.Name == expected); }
public void MyTestInitialize() { underTest = new GlobalCommand("app", "app", Access.Administrator); underTest.AddToConsole(); testWriter = new TestConsoleWriter(); ConsoleBase.RegisterConsoleWriter(testWriter); }
public void MyTestCleanup() { global.RemoveCommand(command); global = null; command = null; CrestronConsole.Messages.Length = 0; }
public void MyTestInitialize() { global = new GlobalCommand("app", "App Command", Access.Administrator); command = new TestCommand(); global.AddCommand(command); global.AddCommand(new TestCommand2()); }
public void Constructor_Sets_Help_WhenShortHelp() { var help = "HelpTest"; var gc = new GlobalCommand("TestTest", help, Access.Administrator); Assert.IsTrue(gc.Help == help); }
public void RemoveFromConsole_ReturnsFalse_WhenNoCommandAdded() { var expected = false; var gc = new GlobalCommand("aps", "help", Access.Administrator); var actual = gc.RemoveFromConsole(); Assert.IsTrue(actual == expected); }
public void AddToConsole_ReturnsTrue_WhenServer_AndConsoleReturnsFalse() { Crestron.SimplSharp.CrestronConsole.AddNewConsoleCommandResult = false; Crestron.SimplSharp.CrestronEnvironment.DevicePlatform = Crestron.SimplSharp.eDevicePlatform.Server; var gc = new GlobalCommand("spa", "Help", Access.Administrator); var actual = gc.AddToConsole(); Assert.IsTrue(actual); }
public void Constructor_Truncates_Help_When_TooLong() { var help = "This help is longer than 79 characters long and is going to be truncated by the constructor."; var expected = "This help is longer than 79 characters long and is going to be truncated by ..."; var gc = new GlobalCommand("TestTest", help, Access.Administrator); Trace.WriteLine("Help: '" + gc.Help + "'"); Assert.IsTrue(gc.Help == expected); }
public void MyTestCleanup() { underTest.RemoveFromConsole(); underTest.Dispose(); underTest = null; Crestron.SimplSharp.CrestronConsole.AddNewConsoleCommandResult = true; Crestron.SimplSharp.CrestronEnvironment.DevicePlatform = Crestron.SimplSharp.eDevicePlatform.Appliance; ConsoleBase.UnregisterConsoleWriter(testWriter); testWriter = null; }
public void RemoveFromConsole_ReturnsTrue_WhenCommandAdded() { var expected = true; var gc = new GlobalCommand("aps", "help", Access.Administrator); Crestron.SimplSharp.CrestronConsole.AddNewConsoleCommandResult = true; gc.AddToConsole(); var actual = gc.RemoveFromConsole(); Assert.IsTrue(actual == expected); }
public void MyTestCleanup() { global.RemoveCommand(command); global = null; command = null; CrestronConsole.Messages.Length = 0; if (writer != null) { ConsoleBase.UnregisterConsoleWriter(writer); } }
public void Dispose_RemovesFromConsole_When_Called() { var c1 = new TestCommand(); var gc = new GlobalCommand("temp", "help", Access.Administrator); gc.AddToConsole(); gc.Dispose(); Assert.IsFalse(gc.RemoveFromConsole()); }
/// <summary> /// Creates a global command, adding it to the <see cref="CrestronConsole"/>. /// </summary> /// <param name="command">The <see cref="GlobalCommand"/> to register.</param> /// <returns><see langword="true"/> if the command is newly registered, <see langword="false"/> if it isn't registered because a command with that name already was.</returns> public static bool RegisterCrestronConsoleCommand(GlobalCommand command) { if (consoleCommandNames.ContainsKey(command.Name)) { return(false); } else { consoleCommandNames.Add(command.Name, command); return(true); } }
public void Constructor_Sets_CommandAccess_Tests() { var gc1 = new GlobalCommand("Test", "Help", Access.Operator); Assert.IsTrue(gc1.CommandAccess == Access.Operator); var gc2 = new GlobalCommand("Test", "Help", Access.Programmer); Assert.IsTrue(gc2.CommandAccess == Access.Programmer); var gc3 = new GlobalCommand("Test", "Help", Access.Administrator); Assert.IsTrue(gc3.CommandAccess == Access.Administrator); }
public void Dispose_RemovesAllCommands_When_Called() { var c1 = new TestCommand(); var gc = new GlobalCommand("temp", "help", Access.Administrator); gc.AddToConsole(); gc.AddCommand(c1); Assert.IsTrue(gc.IsCommandRegistered(c1)); gc.Dispose(); Assert.IsFalse(gc.IsCommandRegistered(c1)); }
public void GetAllGlobalCommands_ReturnsAllGlobalCommands() { Crestron.SimplSharp.CrestronConsole.AddNewConsoleCommandResult = true; var gc2 = new GlobalCommand("sap", "Test", Access.Administrator); gc2.AddToConsole(); var gc3 = new GlobalCommand("spsa", "Test", Access.Operator); gc3.AddToConsole(); var values = GlobalCommand.GetAllGlobalCommands(); Assert.IsTrue(values.Contains(gc2)); Assert.IsTrue(values.Contains(gc3)); Assert.IsTrue(values.Contains(underTest)); }
public void RegisterCommand_WithExistingName_Returns_CommandInUse() { Crestron.SimplSharp.CrestronConsole.AddNewConsoleCommandResult = true; var expected = RegisterResult.CommandNameAlreadyExists; var gc = new GlobalCommand("temp", "temp", Access.Administrator); gc.AddToConsole(); var c1 = new TestCommand(); var c2 = new TestCommand(); c1.RegisterCommand("temp"); var actual = c2.RegisterCommand("temp"); System.Diagnostics.Trace.WriteLine("Register result: '" + actual + "'"); Assert.IsTrue(expected == actual); c1.UnregisterCommand(); gc = null; }
public void Constructor_Throws_ArgumentOutOfRangeException_When_NameTooLong() { var gc = new GlobalCommand("This name is longer than 23 characters.", "Help", Access.Administrator); }
public void Constructor_Throws_ArgumentOutOfRangeException_When_Name_Empty() { var gc = new GlobalCommand(string.Empty, "Help", Access.Administrator); }