Ejemplo n.º 1
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"));
        }
Ejemplo n.º 2
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"));
        }
Ejemplo n.º 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);
        }