public void GetEnumerator_GivenBuildConfigIterator_ShouldReturnDefaultOrderExecution() { //---------------Set up test pack------------------- var serialiser = new PrismaticJsonSerialiser(); var document = GetFile(@"build.json"); var buildConfig = serialiser.Deserialise <DefaultBuildConfig>(document); //---------------Assert Precondition---------------- //---------------Execute Test ---------------------- var defaultBuildIterator = new DefaultBuildIterator(buildConfig); var executedList = new List <List <string> >(); foreach (var buildItem in defaultBuildIterator) { executedList.Add(buildItem); } //---------------Test Result ----------------------- Assert.AreEqual(10, executedList.Count); Assert.AreEqual("before_install.ps1", executedList[0][0]); Assert.AreEqual("install.ps1", executedList[1][0]); Assert.AreEqual("before_script.ps1", executedList[2][0]); Assert.AreEqual("after_script.ps1", executedList[9][0]); }
public void RunScript_GivenGivenBuildConfig_ShouldExecuteAllScriptsInDefaultOrder() { //---------------Set up test pack------------------- var powerShellRunner = new PowerShellRunner(@"Runner"); var serialiser = new PrismaticJsonSerialiser(); var document = GetFile(@"build.json"); var buildConfig = serialiser.Deserialise <DefaultBuildConfig>(document); var defaultBuildIterator = new DefaultBuildIterator(buildConfig); //---------------Assert Precondition---------------- //---------------Execute Test ---------------------- var scriptResults = powerShellRunner.RunScripts(defaultBuildIterator); //---------------Test Result ----------------------- Assert.IsNotNull(scriptResults); Assert.IsTrue(scriptResults.Any()); Assert.AreEqual("Hello World In before_install!", scriptResults[0].ScriptOutput.Replace(Environment.NewLine, "")); Assert.AreEqual("Hello World In install!", scriptResults[1].ScriptOutput.Replace(Environment.NewLine, "")); Assert.AreEqual("Hello World In before_script!", scriptResults[2].ScriptOutput.Replace(Environment.NewLine, "")); Assert.AreEqual("Hello World In script!", scriptResults[3].ScriptOutput.Replace(Environment.NewLine, "")); Assert.AreEqual("Hello World In after_success!", scriptResults[4].ScriptOutput.Replace(Environment.NewLine, "")); Assert.AreEqual("Hello World In after_failure!", scriptResults[5].ScriptOutput.Replace(Environment.NewLine, "")); Assert.AreEqual("Hello World In before_deploy!", scriptResults[6].ScriptOutput.Replace(Environment.NewLine, "")); Assert.AreEqual("Hello World In deploy!", scriptResults[7].ScriptOutput.Replace(Environment.NewLine, "")); Assert.AreEqual("Hello World In after_deploy!", scriptResults[8].ScriptOutput.Replace(Environment.NewLine, "")); Assert.AreEqual("Hello World In after_script!", scriptResults[9].ScriptOutput.Replace(Environment.NewLine, "")); }
public void Deserialise_GivenBuildJsonFile_ShouldReturnBuildObject() { //---------------Set up test pack------------------- var serialiser = new PrismaticJsonSerialiser(); var document = GetFile(@"build.json"); //---------------Assert Precondition---------------- //---------------Execute Test ---------------------- var buildConfig = serialiser.Deserialise <DefaultBuildConfig>(document); //---------------Test Result ----------------------- Assert.IsNotNull(buildConfig); Assert.AreEqual("csharp", buildConfig.Language); Assert.AreEqual("Prismatic.sln", buildConfig.Solution); }
public void Deserialise_GivenJsonFile_ShouldReturnOrderObject() { //---------------Set up test pack------------------- var serialiser = new PrismaticJsonSerialiser(); var stringReader = new StreamReader(@"test.json"); var document = stringReader.ReadToEnd(); //---------------Assert Precondition---------------- Assert.IsTrue(document.Length > 0); //---------------Execute Test ---------------------- var order = serialiser.Deserialise <Order>(new StringReader(document)); //---------------Test Result ----------------------- Assert.IsNotNull(order); Assert.AreEqual("Oz-Ware Purchase Invoice", order.Receipt); Assert.AreEqual(2, order.Items.Count); }