public void Execute_MultipleCommands_CorrectInterpretation() { var xml = new SetupXml() { Commands = new List <DecorationCommandXml>() { new FileDeleteXml() { FileName = "foo.txt", Path = @"C:\Temp\" }, new ExeKillXml() { ProcessName = "bar" }, new WaitXml() { MilliSeconds = "2000" } } }; var helper = new SetupHelper(new ServiceLocator(), new Dictionary <string, ITestVariable>()); var listCommandArgs = helper.Execute(xml.Commands); Assert.That(listCommandArgs.Count(), Is.EqualTo(3)); }
private void ExecuteSetup(SetupXml setup) { try { foreach (var command in setup.Commands) { var skip = false; if (command is IGroupCommand) { var groupCommand = (command as IGroupCommand); if (groupCommand.RunOnce) { skip = groupCommand.HasRun; } } if (!skip) { var impl = new DecorationFactory().Get(command); impl.Execute(); if (command is IGroupCommand) { var groupCommand = (command as IGroupCommand); groupCommand.HasRun = true; } } } } catch (Exception ex) { HandleExceptionDuringSetup(ex); } }
public void Execute_GroupCommand_CorrectlyTransformedToArgs(bool isParallel, Type argsType) { var xml = new SetupXml() { Commands = new List <DecorationCommandXml>() { new CommandGroupXml() { Parallel = isParallel, Commands = new List <DecorationCommandXml>() { new FileDeleteXml() { FileName = "foo.txt", Path = @"C:\Temp\" }, new ExeKillXml() { ProcessName = "bar.exe" } } } } }; var helper = new SetupHelper(new ServiceLocator(), new Dictionary <string, ITestVariable>()); var commandArgs = helper.Execute(xml.Commands).ElementAt(0); Assert.That(commandArgs, Is.AssignableTo(argsType)); var groupCommandArgs = commandArgs as IGroupCommandArgs; Assert.That(groupCommandArgs.Commands.ElementAt(0), Is.AssignableTo <IDeleteCommandArgs>()); Assert.That(groupCommandArgs.Commands.ElementAt(1), Is.AssignableTo <IKillCommandArgs>()); }
public InheritanceTestXml() { categories = new List <string>(); traits = new List <TraitXml>(); setup = new SetupXml(); cleanup = new CleanupXml(); }
public InheritanceTestXml() { categories = new List<string>(); traits = new List<TraitXml>(); setup = new SetupXml(); cleanup = new CleanupXml(); }
public void Execute_InlineTransformationArgument_CorrectlyParsed() { var xml = new SetupXml() { Commands = new List <DecorationCommandXml>() { new FileDeleteXml() { FileName = "@myvar | text-to-upper", Path = @"C:\Temp\" } } }; var myVar = new GlobalVariable(new CSharpScalarResolver <object>( new CSharpScalarResolverArgs("\"foo.txt\"") )); var helper = new SetupHelper(new ServiceLocator(), new Dictionary <string, ITestVariable>() { { "myvar", myVar } }); var deleteCommandArgs = helper.Execute(xml.Commands).ElementAt(0) as IDeleteCommandArgs; Assert.That(deleteCommandArgs.Name, Is.AssignableTo <IScalarResolver>()); Assert.That(deleteCommandArgs.Name.Execute(), Is.EqualTo("FOO.TXT")); Assert.That(deleteCommandArgs.Name.Execute(), Is.Not.EqualTo("foo.txt")); }
public TestXml() { Constraints = new List <AbstractConstraintXml>(); Systems = new List <AbstractSystemUnderTestXml>(); Categories = new List <string>(); Setup = new SetupXml(); Cleanup = new CleanupXml(); Condition = new ConditionXml(); GroupNames = new List <string>(); }
public TestXml() { Constraints = new List<AbstractConstraintXml>(); Systems = new List<AbstractSystemUnderTestXml>(); Categories = new List<string>(); Setup = new SetupXml(); Cleanup = new CleanupXml(); Condition = new ConditionXml(); GroupNames = new List<string>(); }
public TestXml(TestStandaloneXml standalone) { this.Name = standalone.Name; this.DescriptionElement = standalone.DescriptionElement; this.IgnoreElement = standalone.IgnoreElement; this.Categories = standalone.Categories; this.Constraints = standalone.Constraints; this.Setup = standalone.Setup; this.Cleanup = standalone.Cleanup; this.Systems = standalone.Systems; this.UniqueIdentifier = standalone.UniqueIdentifier; this.Edition = standalone.Edition; }
private void ExecuteSetup(SetupXml setup) { try { foreach (var command in setup.Commands) { var impl = new DecorationFactory().Get(command); impl.Execute(); } } catch (Exception ex) { HandleExceptionDuringSetup(ex); } }
public void Execute_CustomCommand_CorrectlyParsed() { var xml = new SetupXml() { Commands = new List <DecorationCommandXml>() { new CustomCommandXml() { AssemblyPath = "NBi.Testing" , TypeName = @"CustomCommand" , Parameters = new List <CustomCommandParameterXml>() { new CustomCommandParameterXml() { Name = "foo", StringValue = "bar" }, new CustomCommandParameterXml() { Name = "quark", StringValue = "@myVar" }, } } } }; var myVar = new GlobalVariable(new LiteralScalarResolver <object>("bar-foo")); var helper = new SetupHelper(new ServiceLocator(), new Dictionary <string, ITestVariable>() { { "myVar", myVar } }); var customCommandArgs = helper.Execute(xml.Commands).ElementAt(0) as ICustomCommandArgs; Assert.That(customCommandArgs.AssemblyPath, Is.TypeOf <LiteralScalarResolver <string> >()); Assert.That(customCommandArgs.AssemblyPath.Execute(), Is.EqualTo("NBi.Testing")); Assert.That(customCommandArgs.TypeName, Is.TypeOf <LiteralScalarResolver <string> >()); Assert.That(customCommandArgs.TypeName.Execute(), Is.EqualTo("CustomCommand")); Assert.That(customCommandArgs.Parameters, Has.Count.EqualTo(2)); Assert.That(customCommandArgs.Parameters["foo"], Is.TypeOf <LiteralScalarResolver <object> >()); var paramValue = customCommandArgs.Parameters["foo"] as LiteralScalarResolver <object>; Assert.That(paramValue.Execute(), Is.EqualTo("bar")); Assert.That(customCommandArgs.Parameters["quark"], Is.TypeOf <GlobalVariableScalarResolver <object> >()); var paramValue2 = customCommandArgs.Parameters["quark"] as GlobalVariableScalarResolver <object>; Assert.That(paramValue2.Execute(), Is.EqualTo("bar-foo")); }
public void Execute_UniqueCommand_CorrectInterpretation() { var xml = new SetupXml() { Commands = new List <DecorationCommandXml>() { new FileDeleteXml() { FileName = "foo.txt", Path = @"C:\Temp\" } } }; var helper = new SetupHelper(new ServiceLocator(), new Dictionary <string, ITestVariable>()); var listCommandArgs = helper.Execute(xml.Commands); Assert.That(listCommandArgs.Count(), Is.EqualTo(1)); }
public void Execute_LiteralArgument_CorrectlyParsed() { var xml = new SetupXml() { Commands = new List <DecorationCommandXml>() { new FileDeleteXml() { FileName = "foo.txt", Path = @"C:\Temp\" } } }; var helper = new SetupHelper(new ServiceLocator(), new Dictionary <string, ITestVariable>()); var deleteCommandArgs = helper.Execute(xml.Commands).ElementAt(0) as IDeleteCommandArgs; Assert.That(deleteCommandArgs.Name, Is.TypeOf <LiteralScalarResolver <string> >()); Assert.That(deleteCommandArgs.Name.Execute(), Is.EqualTo("foo.txt")); }
public void Execute_DecorationCommand_CorrectlyTransformedToArgs(Type xmlType, Type argsType) { var xmlInstance = Activator.CreateInstance(xmlType); Assert.That(xmlInstance, Is.AssignableTo <DecorationCommandXml>()); var xml = new SetupXml() { Commands = new List <DecorationCommandXml>() { xmlInstance as DecorationCommandXml } }; var helper = new SetupHelper(new ServiceLocator(), new Dictionary <string, ITestVariable>()); var commandArgs = helper.Execute(xml.Commands).ElementAt(0); Assert.That(commandArgs, Is.AssignableTo <IDecorationCommandArgs>()); Assert.That(commandArgs, Is.AssignableTo(argsType)); }
private void ExecuteSetup(SetupXml setup, IDictionary <string, ITestVariable> allVariables) { var setupHelper = new SetupHelper(serviceLocator, allVariables); var commands = setupHelper.Execute(setup.Commands); try { foreach (var command in commands) { var skip = false; if (command is IGroupCommand) { var groupCommand = (command as IGroupCommand); if (groupCommand.RunOnce) { skip = groupCommand.HasRun; } } if (!skip) { var impl = new DecorationFactory().Instantiate(command); impl.Execute(); if (command is IGroupCommand) { var groupCommand = (command as IGroupCommand); groupCommand.HasRun = true; } } } } catch (Exception ex) { HandleExceptionDuringSetup(ex); } }
public void Execute_FormatArgument_CorrectlyParsed() { var xml = new SetupXml() { Commands = new List <DecorationCommandXml>() { new FileDeleteXml() { FileName = "~{@myvar}.csv", Path = @"C:\Temp\" } } }; var myVar = new GlobalVariable(new LiteralScalarResolver <object>("bar")); var helper = new SetupHelper(new ServiceLocator(), new Dictionary <string, ITestVariable>() { { "myvar", myVar } }); var deleteCommandArgs = helper.Execute(xml.Commands).ElementAt(0) as IDeleteCommandArgs; Assert.That(deleteCommandArgs.Name, Is.TypeOf <FormatScalarResolver>()); Assert.That(deleteCommandArgs.Name.Execute(), Is.EqualTo("bar.csv")); }
public void AddInheritance(List <string> inheritedCategories, SetupXml inheritedSetup, CleanupXml inheritedCleanup) { this.categories.AddRange(inheritedCategories); InheritDecoration(this.setup, inheritedSetup); InheritDecoration(this.cleanup, inheritedCleanup); }
public void AddInheritance(List<string> inheritedCategories, SetupXml inheritedSetup, CleanupXml inheritedCleanup) { this.categories.AddRange(inheritedCategories); InheritDecoration(this.setup, inheritedSetup); InheritDecoration(this.cleanup, inheritedCleanup); }
private void ExecuteSetup(SetupXml setup) { try { foreach (var command in setup.Commands) { var skip = false; if (command is IGroupCommand) { var groupCommand = (command as IGroupCommand); if (groupCommand.RunOnce) skip = groupCommand.HasRun; } if (!skip) { var impl = new DecorationFactory().Get(command); impl.Execute(); if (command is IGroupCommand) { var groupCommand = (command as IGroupCommand); groupCommand.HasRun=true; } } } } catch (Exception ex) { HandleExceptionDuringSetup(ex); } }