Exemplo n.º 1
0
        public void SetUp()
        {
            Feature = Actors.FeatureWithStepDefinitions;
            Step = Feature.Steps.First();

            Feature.Content =
            @"
                Feature: Name
                Scenario: Name
            ";

            FeatureParser = Create.TestObjectFor<FeatureParser>();

            ObjectFactory.Return<FeatureParserClass>(FeatureParser);

            Given.That(FeatureParser)
                .IgnoringArgs()
                .FeatureFrom("", null)
                .WillReturn(Feature);
        }
Exemplo n.º 2
0
 public void SetUp()
 {
     Feature = Actors.FeatureWithStepDefinitions;
     Step.Table = Actors.ObjectTable;
 }
Exemplo n.º 3
0
        public void should_consider_each_table_columns_as_arg_if_header()
        {
            var Feature = new Feature
            {
                Name = "StepDefinitions",
                Scenarios = { new Scenario { Steps = { new Step
                {
                    Name = "Step",
                    Args = new List<string> { "Arg" },
                    Table = new Table
                    {
                        HasHeader = true,
                        Rows =
                        {
                            new List<string> {"X","Y"},
                            new List<string> {"1","0"}
                        }
                    }
                }
            }}}};

            ObjectFactory.NewFeatureCompiler.Compile(Feature, FeatureItem);

            Feature.Steps[0].Method
                .ShouldBe(Common.StepDefinitions.StepWithThreeArgs);
        }
Exemplo n.º 4
0
        public void should_resolve_method_overloading_by_Arg_type()
        {
            typeof(string).IsArray.ShouldBeFalse();

            var Feature = new Feature
            {
                DeclaredStepDefinitions = { "StepDefinitions" },
                Scenarios = { new Scenario { Steps =
                {
                    new Step { Name = "Step", Args = new List<string> { "42" }, },
                    new Step { Name = "Step", Args = new List<string> { "Arg" },},
                }
            }}};

            ObjectFactory.NewFeatureCompiler.Compile(Feature, FeatureItem);

            Feature.Steps[0].Method
                .ShouldBe(Common.StepDefinitions.StepOverloadedInt);

            Feature.Steps[1].Method
                .ShouldBe(Common.StepDefinitions.StepOverloaded);
        }
Exemplo n.º 5
0
        public void should_resolve_method_overloading_by_Arg_count()
        {
            var Feature = new Feature
            {
                DeclaredStepDefinitions = { "StepDefinitions" },
                Scenarios = { new Scenario { Steps =
                {
                    new Step { Name = "Step", Args = new List<string> { "Arg" }, },
                    new Step { Name = "Step", Args = new List<string> { "Arg1", "2", "\"Arg3\"" }, },
                }
            }}};

            ObjectFactory.NewFeatureCompiler.Compile(Feature, FeatureItem);

            Feature.Steps[0].Method
                .ShouldBe(Common.StepDefinitions.StepOverloaded);

            Feature.Steps[1].Method
                .ShouldBe(Common.StepDefinitions.StepWithThreeArgs);
        }
Exemplo n.º 6
0
        public void should_not_find_private_Steps_in_StepDefitions()
        {
            var Feature = new Feature
            {
                Name = "StepDefinitions",
                Scenarios = { new Scenario { Steps = { new Step { Name = "StepPrivate", } }
            }}};

            ObjectFactory.NewFeatureCompiler.Compile(Feature, FeatureItem);

            Feature.Steps[0].Method
                .ShouldBe(Common.StepDefinitions.PrivateStep);
        }
Exemplo n.º 7
0
        public void should_match_Header_to_ObjectArg_field(string UserName)
        {
            Feature = new Feature
            {
                Name = "StepDefinitions",
                DeclaredStepDefinitions = new List<string> { "StepDefinitions" },
                Scenarios = { new Scenario { Steps = { new Step
                {
                    Name = "Step_with_object",
                    Table = new Table
                    {
                        HasHeader = true,
                        Rows = { new List<string> { UserName } }
                    }
                }}
            }}};

            ObjectFactory.NewFeatureCompiler.Compile(Feature, FeatureItem);

            Feature.Steps[0].Method
                .ShouldBe(Common.StepDefinitions.StepWithObject);
        }
Exemplo n.º 8
0
        public void should_find_Step_in_DefaultStepDefitions()
        {
            var Feature = new Feature
            {
                Name = "StepDefinitions",
                Scenarios = { new Scenario { Steps = { new Step { Name = "Step", } }
            }}};

            ObjectFactory.NewFeatureCompiler.Compile(Feature, FeatureItem);

            Feature.Steps[0].Method
                .ShouldBe(Common.StepDefinitions.StepMethod);
        }
Exemplo n.º 9
0
        public void should_find_private_Steps_in_other_DefaultStepDefitions()
        {
            var Feature = new Feature
            {
                Name = "FeatureName",
                Scenarios = { new Scenario { Steps = { new Step { Name = "StepPrivate", } }
            }}};

            ObjectFactory.NewFeatureCompiler.Compile(Feature, FeatureItem);

            Feature.Steps[0].Method.ShouldBeNull();
        }
Exemplo n.º 10
0
        public static CodeGenerator NewStepDefinitionsGenerator(Feature Feature, string ExistingStepDefinitions)
        {
            if (Feature is InvalidFeature) return new InvalidStepDefinitionsGenerator(ExistingStepDefinitions);

            return new StepDefinitionsGenerator(Feature, ExistingStepDefinitions);
        }
Exemplo n.º 11
0
        public static CodeGenerator NewRunnerGenerator(Feature Feature)
        {
            if (Feature is InvalidFeature) return new InvalidRunnerGenerator(Feature as InvalidFeature);

            return new RunnerGenerator(Feature);
        }