Ejemplo n.º 1
0
 public void MyTestInitialize()
 {
     underTest = new GlobalCommand("app", "app", Access.Administrator);
     underTest.AddToConsole();
     testWriter = new TestConsoleWriter();
     ConsoleBase.RegisterConsoleWriter(testWriter);
 }
Ejemplo n.º 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());
 }
Ejemplo n.º 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);
        }
Ejemplo n.º 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());
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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();
        }
Ejemplo n.º 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));
        }
Ejemplo n.º 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));
        }
Ejemplo n.º 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;
        }