Exemplo n.º 1
0
        public void GivenConfigWithProjectWithJobAndUpdateSteamWorkshopItemTask__WhenParsing__JobShouldHaveTask()
        {
            const string lua = @"
                local p = project('test')
                local j = p:add_job('test-job')
                j:add_task(update_steam_workshop_item {
                    app_id = 32470,
                    title = 'my-test-item',
                    description_file = 'path/to/description',
                    item_folder = 'path/to/folder',
                    visibility = visibility.private,
                    language = 'English'
                })  
            ";

            _mockFileData.TextContents = lua;

            JobStub   jobStub   = new JobStub();
            TaskDummy taskDummy = new TaskDummy();
            BuildComponentFactoryStub factoryStub = MakeBuildComponentFactoryStub(jobStub, taskDummy);

            MakeSutAndParse(factoryStub);

            ITask actualTask = jobStub.Tasks.First();

            Assert.AreEqual(taskDummy, actualTask);
        }
Exemplo n.º 2
0
        public void GivenProjectWithJobAndTwoTasks__WhenCallingParse__ShouldAddBothTasksToJob()
        {
            const string xml = @"<?xml version=""1.0"" encoding=""UTF-8""?>
                                <eaw-ci:BuildConfiguration
                                  ConfigVersion=""1.0.0"" 
                                  xmlns:eaw-ci=""eaw-ci""
                                  xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"">
                                  <Projects>
                                    <Project Id=""idvalue0"">
                                      <Jobs>
                                        <Job Id=""idvalue1"" Name=""TestJob"">
                                          <Tasks>
                                            <Task Id=""idvalue2"" Name=""FirstTask"" xsi:type=""eaw-ci:Copy"">
                                              <CopyFromPath>path/to/first/source</CopyFromPath>
                                              <CopyToPath>path/to/first/dest</CopyToPath>
                                              <CopySubfolders>true</CopySubfolders>
                                              <CopyFileByPattern>*</CopyFileByPattern>
                                              <AlwaysOverwrite>false</AlwaysOverwrite>
                                            </Task>

                                            <Task Id=""idvalue3"" Name=""SecondTask"" xsi:type=""eaw-ci:Copy"">
                                              <CopyFromPath>path/to/second/source</CopyFromPath>
                                              <CopyToPath>path/to/second/dest</CopyToPath>
                                              <CopySubfolders>true</CopySubfolders>
                                              <CopyFileByPattern>*</CopyFileByPattern>
                                              <AlwaysOverwrite>false</AlwaysOverwrite>
                                            </Task>
                                          </Tasks>
                                        </Job>
                                      </Jobs>
                                    </Project>
                                  </Projects>
                                </eaw-ci:BuildConfiguration>";

            _mockFileData.TextContents = xml;

            JobStub   jobStub    = new JobStub();
            TaskDummy firstTask  = new TaskDummy();
            TaskDummy secondTask = new TaskDummy();

            IteratingTaskBuilderStub taskBuilderStub = new IteratingTaskBuilderStub();

            taskBuilderStub.Tasks.Add(firstTask);
            taskBuilderStub.Tasks.Add(secondTask);

            BuildComponentFactoryStub factoryStub = new BuildComponentFactoryStub
            {
                Job = jobStub, TaskBuilder = taskBuilderStub
            };
            XmlBuildConfigParser sut = new XmlBuildConfigParser(_fileSystem, factoryStub);

            sut.Parse(Path);

            AssertJobHasExpectedTask(jobStub, firstTask);
            AssertJobHasExpectedTask(jobStub, secondTask);
        }
Exemplo n.º 3
0
        public void GivenLuaJobWithJob__WhenCallingAddTask__ContainedJobShouldHaveTask()
        {
            JobStub   jobStub   = new JobStub();
            TaskDummy taskDummy = new TaskDummy();

            LuaJob      sut         = new LuaJob(jobStub);
            LuaTaskStub luaTaskStub = new LuaTaskStub {
                Task = taskDummy
            };

            sut.add_task(luaTaskStub);

            CollectionAssert.Contains(jobStub.Tasks, taskDummy);
        }
Exemplo n.º 4
0
        public void GivenConfigWithProjectWithJobAndCopyTask__WhenParsing__JobShouldHaveTask()
        {
            const string lua = @"
                local p = project('test')
                local j = p:add_job('test-job')
                j:add_task(copy('a', 'b'))  
            ";

            _mockFileData.TextContents = lua;

            JobStub   jobStub   = new JobStub();
            TaskDummy taskDummy = new TaskDummy();
            BuildComponentFactoryStub factoryStub = MakeBuildComponentFactoryStub(jobStub, taskDummy);

            MakeSutAndParse(factoryStub);

            ITask actualTask = jobStub.Tasks.First();

            Assert.AreEqual(taskDummy, actualTask);
        }
Exemplo n.º 5
0
        public void GivenLuaJobWithJob__WhenCallingAddTasks__ContainedJobShouldHaveAllTasks()
        {
            using NLua.Lua luaInterpreter = new NLua.Lua();

            TaskDummy firstTaskDummy  = new TaskDummy();
            TaskDummy secondTaskDummy = new TaskDummy();

            LuaTable taskTable = MakeLuaTable(luaInterpreter, "taskTable");

            taskTable[1] = new LuaTaskStub {
                Task = firstTaskDummy
            };
            taskTable[2] = new LuaTaskStub {
                Task = secondTaskDummy
            };

            JobStub jobStub = new JobStub();
            LuaJob  sut     = new LuaJob(jobStub);

            sut.add_tasks(taskTable);

            ITask[] expectedTasks = { firstTaskDummy, secondTaskDummy };
            CollectionAssert.AreEqual(expectedTasks, jobStub.Tasks);
        }
Exemplo n.º 6
0
        private static BuildComponentFactoryStub MakeBuildComponentFactoryStub(JobDummy job, TaskDummy task = null)
        {
            BuildComponentFactoryStub factoryStub = new BuildComponentFactoryStub
            {
                Project     = new ProjectStub(),
                Job         = job,
                TaskBuilder = new TaskBuilderStub
                {
                    Task = task ?? new TaskDummy()
                }
            };

            return(factoryStub);
        }