예제 #1
0
        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));
        }
예제 #2
0
파일: TestSuite.cs 프로젝트: jeason0813/NBi
        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);
            }
        }
예제 #3
0
        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>());
        }
예제 #4
0
 public InheritanceTestXml()
 {
     categories = new List <string>();
     traits     = new List <TraitXml>();
     setup      = new SetupXml();
     cleanup    = new CleanupXml();
 }
예제 #5
0
 public InheritanceTestXml()
 {
     categories = new List<string>();
     traits = new List<TraitXml>();
     setup = new SetupXml();
     cleanup = new CleanupXml();
 }
예제 #6
0
        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"));
        }
예제 #7
0
파일: TestXml.cs 프로젝트: zyh329/nbi
 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>();
 }
예제 #8
0
파일: TestXml.cs 프로젝트: zyh329/nbi
 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>();
 }
예제 #9
0
파일: TestXml.cs 프로젝트: zyh329/nbi
 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;
 }
예제 #10
0
파일: TestXml.cs 프로젝트: zyh329/nbi
 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;
 }
예제 #11
0
파일: TestSuite.cs 프로젝트: zyh329/nbi
 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);
     }
 }
예제 #12
0
        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"));
        }
예제 #13
0
        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));
        }
예제 #14
0
        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"));
        }
예제 #15
0
        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));
        }
예제 #16
0
        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);
            }
        }
예제 #17
0
        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"));
        }
예제 #18
0
 public void AddInheritance(List <string> inheritedCategories, SetupXml inheritedSetup, CleanupXml inheritedCleanup)
 {
     this.categories.AddRange(inheritedCategories);
     InheritDecoration(this.setup, inheritedSetup);
     InheritDecoration(this.cleanup, inheritedCleanup);
 }
예제 #19
0
 public void AddInheritance(List<string> inheritedCategories, SetupXml inheritedSetup, CleanupXml inheritedCleanup)
 {
     this.categories.AddRange(inheritedCategories);
     InheritDecoration(this.setup, inheritedSetup);
     InheritDecoration(this.cleanup, inheritedCleanup);
 }
예제 #20
0
파일: TestSuite.cs 프로젝트: zyh329/nbi
 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);
     }
 }
예제 #21
0
파일: TestSuite.cs 프로젝트: jansaris/NBi
        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);
            }
        }