예제 #1
0
        public void Run_should_log_file_not_found()
        {
            // given
            var mockTask         = new MockTask();
            var yamlConfigReader = new YamlConfigParserMock();

            yamlConfigReader.ExpectedTasks = new List <ITask>()
            {
                mockTask
            };

            var locator = new ServiceLocatorMock();

            locator.Register <IYamlConfigParser>(yamlConfigReader);
            locator.Register <ILogger>(_logger);

            var command = new RunCommand();

            command.Logger              = _logger;
            command.ConfigFile          = "doesnt-exist.yml";
            command.ConfigBaseDirectory = AppDomain.CurrentDomain.BaseDirectory;

            // when
            command.Run(locator);

            // then
            Assert.That(mockTask.HasRun, Is.False);
            Assert.That(_logStringBuilder.ToString(), Does.Contain("The Yaml config file"));
            Assert.That(_logStringBuilder.ToString(), Does.Contain("doesnt-exist.yml' does not exist"));
        }
예제 #2
0
        public void Run_should_execute_tasks_from_custom_config()
        {
            // given

            var mockTask         = new MockTask();
            var yamlConfigReader = new YamlConfigParserMock();

            yamlConfigReader.ExpectedTasks = new List <ITask>()
            {
                mockTask
            };

            var locator = new ServiceLocatorMock();

            locator.Register <IYamlConfigParser>(yamlConfigReader);
            locator.Register <ILogger>(_logger);

            var command = new RunCommand();

            command.Logger              = _logger;
            command.ConfigFile          = "test-config.yml";
            command.ConfigBaseDirectory = AppDomain.CurrentDomain.BaseDirectory;

            // when
            command.Run(locator);

            // then
            Assert.That(mockTask.HasRun, Is.True);
            Assert.That(_logStringBuilder.ToString(), Does.Contain("MockTask run info log"));
        }
예제 #3
0
        public void Run_should_use_remy_yml_by_default()
        {
            // given
            var mockTask         = new MockTask();
            var yamlConfigReader = new YamlConfigParserMock();

            yamlConfigReader.ExpectedTasks = new List <ITask>()
            {
                mockTask
            };

            var locator = new ServiceLocatorMock();

            locator.Register <IYamlConfigParser>(yamlConfigReader);
            locator.Register <ILogger>(_logger);

            var command = new RunCommand();

            command.Logger = _logger;
            command.ConfigBaseDirectory = AppDomain.CurrentDomain.BaseDirectory;

            // when
            command.Run(locator);

            // then
            Assert.That(mockTask.HasRun, Is.True);
        }
예제 #4
0
        public void Run_should_parse_install_command()
        {
            // Arrange
            var locator = new ServiceLocatorMock();

            var pluginManager = new PluginManagerMock();

            pluginManager.Packages.Add(new DataServicePackage()
            {
                Id              = "DonkeyKong",
                Tags            = "remy-plugin",
                IsLatestVersion = true
            });

            var command = new PluginsCommand(pluginManager);

            command.Logger  = _logger;
            command.Install = "DonkeyKong";

            // Act
            command.Run(locator);

            // Assert
            Assert.That(_logStringBuilder.ToString(), Does.Contain("Downloading plugin 'DonkeyKong'"));
            Assert.True(pluginManager.Downloaded);
        }
예제 #5
0
        public void GetNugetSource_should_default_to_nuget_repo()
        {
            // Arrange
            var locator       = new ServiceLocatorMock();
            var pluginManager = new PluginManagerMock();

            var command = new PluginsCommand(pluginManager);

            command.Logger  = _logger;
            command.Install = "ThePackage";

            // Act
            command.Run(locator);

            // Assert
            Assert.That(command.Source, Is.EqualTo("https://packages.nuget.org/api/v2"));
        }
예제 #6
0
        public void Run_should_write_example_yaml()
        {
            // given
            var fileProvider = new FileProviderMock();

            fileProvider.CurrentDirectory = "mypath/";
            string expectedPath = Path.Combine(fileProvider.GetCurrentDirectory(), "remy.yml");

            var locator = new ServiceLocatorMock();
            var command = new InitCommand(fileProvider);

            command.Logger = _logger;

            // when
            command.Run(locator);

            // then
            Assert.That(fileProvider.FileWriteContent, Is.Not.Null);
            Assert.That(fileProvider.FileWritePath, Is.Not.Null);

            Assert.That(fileProvider.FileWriteContent, Does.Contain("echo 'Hello from Remy!'"));
            Assert.That(fileProvider.FileWritePath, Is.EqualTo(expectedPath));
            Assert.That(_logStringBuilder.ToString(), Does.Contain("Example remy.yml file written"));
        }
예제 #7
0
        public void Run_should_parse_list_command()
        {
            // Arrange
            var locator = new ServiceLocatorMock();

            var pluginManager = new PluginManagerMock();

            pluginManager.Packages.Add(new DataServicePackage()
            {
                Id              = "SilverBack",
                Tags            = "remy-plugin",
                Description     = "This plugin gives the Silverback framework a banana.",
                IsLatestVersion = true
            });
            pluginManager.Packages.Add(new DataServicePackage()
            {
                Id              = "BumsOnATrain",
                Tags            = "remy-plugin",
                Description     = "Choo choo.",
                IsLatestVersion = true,
                Version         = "1.0.1"
            });

            var command = new PluginsCommand(pluginManager);

            command.Logger = _logger;
            command.List   = true;

            // Act
            command.Run(locator);

            // Assert
            Assert.That(_logStringBuilder.ToString(), Does.Contain("Plugins available (tagged 'remy-plugin'):"));
            Assert.That(_logStringBuilder.ToString(), Does.Contain("SilverBack - This plugin gives the Silverback framework a banana."));
            Assert.That(_logStringBuilder.ToString(), Does.Contain("BumsOnATrain 1.0.1 - Choo choo."));
        }