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);
        }
Esempio n. 2
0
 public void SetUp()
 {
     Feature = Actors.FeatureWithStepDefinitions;
     Step.Table = Actors.ObjectTable;
 }
        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);
        }
        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);
        }
        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);
        }
        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);
        }
        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);
        }
        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);
        }
        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();
        }
Esempio n. 10
0
        public static CodeGenerator NewStepDefinitionsGenerator(Feature Feature, string ExistingStepDefinitions)
        {
            if (Feature is InvalidFeature) return new InvalidStepDefinitionsGenerator(ExistingStepDefinitions);

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

            return new RunnerGenerator(Feature);
        }