Exemplo n.º 1
0
        public MethodIdentity(IGherkinBlock scenario)
        {
            // try and get some kind of test case identifier from the comments
            var maybe = scenario.Comments.Find(GherkinIdRef.ScenarioId);

            this.Id = maybe.HasValue ? maybe.Value.Value : Guid.NewGuid().ToString();
        }
Exemplo n.º 2
0
 public BackgroundBuilder(IGherkinBlock item)
 {
     this.result = new FixtureBackground(FixtureStep.Create(GherkinKeyword.Background, item.Name));
     this.result.AddComments(item.Gherkin);
     this.result.AddChild(Steps(GherkinStep.Given, item));
     this.result.AddChild(Steps(GherkinStep.When, item));
 }
Exemplo n.º 3
0
        public FixtureMethodBuilder(IGherkinBlock background, IGherkinScenario scenario, ISpockOptions options, IFixtureInvariants fixtureInvariants)
        {
            if (string.IsNullOrEmpty(scenario.Name))
            {
                throw new GherkinException(
                          GherkinExceptionType.InvalidGherkin,
                          "No value representing the Scenario name found in the Gherkin feature file.");
            }

            this.background        = background;
            this.scenario          = scenario;
            this.options           = options;
            this.fixtureInvariants = fixtureInvariants;
        }
Exemplo n.º 4
0
        public FixtureMethod(
            IGherkinBlock background,
            IMethods methods,
            IGherkinScenario scenario,
            ISpockOptions options,
            IFixtureInvariants fixtureInvariants)
            : base(options, fixtureInvariants)
        {
            this.background = background;
            this.scenario   = scenario;
            this.Methods    = methods;
            this.Identity   = new MethodIdentity(scenario);

            var methodBuilder = SyntaxScenario.For(scenario);

            this.Signature = methodBuilder.Signature;
            this.TestCases = methodBuilder.TestCases;
        }
Exemplo n.º 5
0
        private SyntaxScenarioSteps(
            IGherkinBlock background,
            IGherkinBlockSteps context,
            IMethod method,
            IEnumerable <string> whereDeclaration,
            string whereCallSyntax)
        {
            var hasSteps = false;

            this.steps = new List <string>();
            var callSyntax = new List <string>();

            if (background != null)
            {
                foreach (var s in SyntaxScenarioStep.CreateBuilder.For(background.Steps))
                {
                    hasSteps = true;
                    callSyntax.Add(s.CallSyntax);
                }
            }

            var builders = SyntaxScenarioStep.CreateBuilder.For(context);

            if (builders.Any())
            {
                hasSteps = true;
                if (whereDeclaration != null)
                {
                    this.steps.AddRange(whereDeclaration);
                    callSyntax.Add(whereCallSyntax);
                }
            }

            foreach (var builder in builders)
            {
                this.steps.AddRange(builder.Syntax);
                callSyntax.Add(builder.CallSyntax);
            }

            this.Method = !hasSteps
                ? method
                : new TestMethodPrivate(method, callSyntax);
        }
Exemplo n.º 6
0
        public static ISyntaxScenarioSteps For(
            IGherkinBlock background,
            IGherkinBlockSteps context,
            IMethods methods,
            IMethodSignature signature,
            bool hasTestCases)
        {
            ISpockElements <string> whereDeclaration = null;
            var whereCallSyntax = string.Empty;

            if (hasTestCases)
            {
                whereDeclaration = methods.Implementation.Declaration(signature);
                whereCallSyntax  = methods.Implementation.CallSyntax(signature);
            }

            return(new SyntaxScenarioSteps(
                       background,
                       context,
                       methods.Specification,
                       whereDeclaration,
                       whereCallSyntax));
        }
 /// <inheritdoc />
 protected override void When(IGherkinFeature sut)
 {
     this.background = this.Sut.Background;
     this.given      = this.Sut.Background.Steps.ElementAt(0);
     this.and        = this.Sut.Background.Steps.ElementAt(1);
 }