Exemple #1
0
 public void MyTestInitialize()
 {
     underTest = new GlobalCommand("app", "app", Access.Administrator);
     underTest.AddToConsole();
     testWriter = new TestConsoleWriter();
     ConsoleBase.RegisterConsoleWriter(testWriter);
 }
Exemple #2
0
 public void MyTestInitialize()
 {
     global = new GlobalCommand("app", "App Command", Access.Administrator);
     global.AddToConsole();
     command = new TestCommand();
     global.AddCommand(command);
     global.AddCommand(new TestCommand2());
 }
Exemple #3
0
        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);
        }
Exemple #4
0
        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());
        }
Exemple #5
0
        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);
        }
Exemple #6
0
        public void AddToConsole_ReturnsFalse_WhenSameCommandAdded()
        {
            var expected = false;
            var gc       = new GlobalCommand("aps", "help", Access.Administrator);

            gc.AddToConsole();

            var gc2    = new GlobalCommand("aps", "help", Access.Administrator);
            var actual = gc2.AddToConsole();

            Assert.IsTrue(expected == actual);
            gc.RemoveFromConsole();
        }
Exemple #7
0
        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));
        }
Exemple #8
0
        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));
        }
Exemple #9
0
        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;
        }