GivenUnixLikeSystem_And_Config_With_OneProject_OneJob_And_RunProcessTask__WhenRunning__ShouldRunProcess() { const string config = @" local proj = project('pid0') local job = proj:add_job('My-Job') job:add_task( run_process('echo') :arguments('Hello World') ) "; CreateConfigFile(config); StringBuilder stringBuilder = new StringBuilder(); Console.SetOut(new StringWriter(stringBuilder)); RunOptions options = new RunOptions { BackendLua = true, ConfigPath = "eaw-ci.lua", ProjectName = "pid0", JobName = "My-Job" }; EawXBuildApplication sut = new EawXBuildApplication(_services.BuildServiceProvider(), options); sut.Run(); string actual = stringBuilder.ToString().Trim(); Assert.AreEqual("Hello World", actual); }
public void GivenConfig_With_OneProject_OneJob_And_CopyTask__WhenRunning__ShouldCopyToTargetLocation() { const string config = @" local proj = project('pid0') local job = proj:add_job('My-Job') job:add_task(copy('eaw-ci.lua', 'newfile.lua')) "; CreateConfigFile(config); RunOptions options = new RunOptions { BackendLua = true, ConfigPath = "eaw-ci.lua", ProjectName = "pid0", JobName = "My-Job" }; EawXBuildApplication sut = new EawXBuildApplication(_services.BuildServiceProvider(), options); sut.Run(); bool actual = _fileSystem.File.Exists("newfile.lua"); Assert.IsTrue(actual); }
public void WhenCalledWithInvalidRunOptions__ThenCorrectError() { EawXBuildApplication app = new EawXBuildApplication( TestUtility.GetConfiguredServiceCollection().BuildServiceProvider(), new RunOptions { BackendLua = false, BackendXml = false }); ExitCode exitCode = app.Run(); Assert.AreEqual(ExitCode.ExUsage, exitCode); }
public void GivenAValidServiceProvider__RequiredServicesResolveBackendCorrectly() { EawXBuildApplication app = new EawXBuildApplication( TestUtility.GetConfiguredServiceCollection().BuildServiceProvider(), new RunOptions()); IBuildConfigParser xmlParser = app.GetXmlBuildConfigParserInternal(app.Services.GetService <IIOHelperService>()); Assert.IsInstanceOfType(xmlParser, typeof(XmlBuildConfigParser)); IBuildConfigParser luaParser = app.GetLuaBuildConfigParserInternal(); Assert.IsInstanceOfType(luaParser, typeof(LuaBuildConfigParser)); }
public void WhenRunningWith_OneProject_OneJob_And_CopyTask__ShouldCopyFileToTarget() { RunOptions options = new RunOptions { BackendXml = true, ConfigPath = "eaw-ci.xml", ProjectName = "pid0", JobName = "My-Job" }; CreateXmlConfigWithTask(CopyTask); EawXBuildApplication sut = new EawXBuildApplication(_services.BuildServiceProvider(), options); sut.Run(); bool actual = _fileSystem.File.Exists("newfile.xml"); Assert.IsTrue(actual); }
public void GivenUnixLikeSystem__WhenRunningWith_OneProject_OneJob_And_RunProgramTask__ShouldRunProgram() { RunOptions options = new RunOptions { BackendXml = true, ConfigPath = "eaw-ci.xml", ProjectName = "pid0", JobName = "My-Job" }; CreateXmlConfigWithTask(EchoTask); StringBuilder stringBuilder = new StringBuilder(); Console.SetOut(new StringWriter(stringBuilder)); EawXBuildApplication sut = new EawXBuildApplication(_services.BuildServiceProvider(), options); sut.Run(); string actual = stringBuilder.ToString().Trim(); Assert.AreEqual("Hello World", actual); }