Inheritance: IConsole
Ejemplo n.º 1
0
        public void ExecutePrintsNothingIfNoArgumentsAndNoSetPropertiesAreSpecified()
        {
            // Arrange
            var settings = Mock.Of<ISettings>();
            var console = new MockConsole();
            var command = new ConfigCommand(settings)
                                {
                                    Console = console
                                };

            // Act
            command.ExecuteCommand();

            // Assert
            Assert.Empty(console.Output);
        }
Ejemplo n.º 2
0
        public void SpecifiedPropertiesAreDeletedIfNoValueIsProvidedToSetProperties()
        {
            // Arrange
            var settings = new Mock<ISettings>(MockBehavior.Strict);
            settings.Setup(s => s.DeleteValue("config", "test")).Returns(true).Verifiable();

            var console = new MockConsole();
            var command = new ConfigCommand(settings.Object)
            {
                Console = console,
            };
            command.Set.Add("test", "");

            // Act
            command.ExecuteCommand();

            // Assert
            settings.Verify();
        }
Ejemplo n.º 3
0
        public void ExecutePrintsValueOfKeyIfArgumentIsSpecified()
        {
            // Arrange
            var settings = new Mock<ISettings>(MockBehavior.Strict);
            settings.Setup(s => s.GetValue("config", "test")).Returns("value").Verifiable();

            var console = new MockConsole();
            var command = new ConfigCommand(settings.Object)
            {
                Console = console,
            };
            command.Arguments.Add("test");

            // Act
            command.ExecuteCommand();

            // Assert
            Assert.Equal("value", console.Output.Trim());
            settings.Verify();
        }
Ejemplo n.º 4
0
        public void SpecifiedPropertiesAreSetInConfig()
        {
            // Arrange
            var settings = new Mock<ISettings>(MockBehavior.Strict);
            settings.Setup(s => s.SetValue("config", "test", "value2")).Verifiable();
            settings.Setup(s => s.SetValue("config", "test2", "value1")).Verifiable();

            var console = new MockConsole();
            var command = new ConfigCommand(settings.Object)
            {
                Console = console,
            };
            command.Set.Add("test", "value2");
            command.Set.Add("test2", "value1");

            // Act
            command.ExecuteCommand();

            // Assert
            settings.Verify();
        }
Ejemplo n.º 5
0
        public void SpecifiedPropertiesAreSetInConfig()
        {
            // Arrange
            var settings = new Mock <ISettings>(MockBehavior.Strict);

            settings.Setup(s => s.SetValue("config", "test", "value2")).Verifiable();
            settings.Setup(s => s.SetValue("config", "test2", "value1")).Verifiable();

            var console = new MockConsole();
            var command = new ConfigCommand(settings.Object)
            {
                Console = console,
            };

            command.Set.Add("test", "value2");
            command.Set.Add("test2", "value1");

            // Act
            command.ExecuteCommand();

            // Assert
            settings.Verify();
        }
Ejemplo n.º 6
0
        public void ExecutePrintsValueOfKeyIfArgumentIsSpecified()
        {
            // Arrange
            var settings = new Mock <ISettings>(MockBehavior.Strict);

            settings.Setup(s => s.GetValue("config", "test", false)).Returns("value").Verifiable();

            var console = new MockConsole();
            var command = new ConfigCommand()
            {
                Settings = settings.Object,
                Console  = console,
            };

            command.Arguments.Add("test");

            // Act
            command.ExecuteCommand();

            // Assert
            Assert.Equal("value", console.Output.Trim());
            settings.Verify();
        }