Пример #1
0
 public void Pack_depends_on_Build_and_Dummy()
 {
     var sut = new TaskConfiguration(typeof(MyWrapperClass.Pack));
     var deps = sut.GetDependencies(Setup.FakeScriptParamsObject());
     deps[0].Should().Be<MyWrapperClass.Build>();
     deps[1].Should().Be<MyWrapperClass.Dummy>();
 }
Пример #2
0
        public TaskConfiguration CreateConfiguration(Type type)
        {
            var config = new TaskConfiguration(type);
            
            _tasks.Add(config);

            return config;
        }
Пример #3
0
        public TaskConfiguration CreateConfiguration(Type type)
        {
            var config = new TaskConfiguration(type);

            _tasks.Add(config);

            return(config);
        }
 public TaskConditionalConfiguration(TaskConfiguration parent, Func <IScriptParams, bool> condition = null)
 {
     _parent = parent;
     if (condition != null)
     {
         _condition = condition;
     }
     ShouldExecute = true;
 }
 public void Build_shouldnt_execute_when_condition()
 {
     var sut = new TaskConfiguration(typeof(MyWrapperClass.Build));
     var build = new MyWrapperClass.Build(sut);
     var init = Setup.FakeScriptParamsObject();
     
     sut.ShouldExecute(init).Should().BeTrue();
     
     init.RawArguments[0] = "skip";
     sut.ShouldExecute(init).Should().BeFalse();
 }
Пример #6
0
 TaskExecutor GetExecutor(TaskConfiguration config, TaskContext context)
 {
     var deps = config.GetDependencies(context.InitData);
     var execDeps = new TaskExecutor[deps.Length];
     for (var i = 0; i < deps.Length; i++)
     {
         var typeConfig = _tasks.Find(d => d.Type == deps[i]);
         if (typeConfig==null)throw new InvalidOperationException("Can't find task '{0}'".ToFormat(deps[i].Name));
         execDeps[i] = GetExecutor(typeConfig, context);
     }
     if (!config.ShouldExecute(context.InitData)) return TaskExecutor.SkipTask;
     var method = _configuration.GetExecutableMethod(config.Type);
     
     return new TaskExecutor(config.Instance,method,execDeps);
 }
Пример #7
0
        TaskExecutor GetExecutor(TaskConfiguration config, TaskContext context)
        {
            var deps     = config.GetDependencies(context.InitData);
            var execDeps = new TaskExecutor[deps.Length];

            for (var i = 0; i < deps.Length; i++)
            {
                var typeConfig = _tasks.Find(d => d.Type == deps[i]);
                if (typeConfig == null)
                {
                    throw new InvalidOperationException("Can't find task '{0}'".ToFormat(deps[i].Name));
                }
                execDeps[i] = GetExecutor(typeConfig, context);
            }

            var method = _configuration.GetExecutableMethod(config.Type);

            return(new TaskExecutor(config.Instance, method, execDeps));
        }
Пример #8
0
        public TaskExecutor BuildExecutor(TaskContext context)
        {
            var name = context.RequestedTask;
            TaskConfiguration task = null;

            if (name.IsNullOrEmpty())
            {
                task = _tasks.FirstOrDefault(d => d.IsDefault);
                if (task == null)
                {
                    throw new InvalidOperationException("There's no default task specified. Either specify a script name or annotate a task with [Default]");
                }
            }
            else
            {
                task = _tasks.Find(d => d.Type.Name == name);
                if (task == null)
                {
                    throw new InvalidOperationException("Can't find task '{0}'".ToFormat(name));
                }
            }
            return(GetExecutor(task, context));
        }
Пример #9
0
 public void Dummy_depends_on_Clean()
 {
     var sut = new TaskConfiguration(typeof(MyWrapperClass.Dummy));
     var deps=sut.GetDependencies(Setup.FakeScriptParamsObject());
     deps[0].Should().Be<MyWrapperClass.Clean>();
 }
Пример #10
0
 public void Clean_has_no_dependencies()
 {
     var sut = new TaskConfiguration(typeof(MyWrapperClass.Clean));
     sut.GetDependencies(Setup.FakeScriptParamsObject()).Should().BeEmpty();
 }