Inheritance: Node, INodeHolder
コード例 #1
0
 public IExecutionStep CreatePlan(Step step, FixtureLibrary library)
 {
     return new SilentAction("Grammar", _position, _action, step)
     {
         Subject = Key
     };
 }
コード例 #2
0
 public IExecutionStep CreatePlan(Step step, FixtureLibrary library, bool inTable = false)
 {
     return new SilentAction("Grammar", Position, _action, step)
     {
         Subject = Key
     };
 }
コード例 #3
0
ファイル: Section.cs プロジェクト: jamesmanning/Storyteller
        public Step AddStep(string key)
        {
            var step = new Step(key);
            Children.Add(step);

            return step;
        }
コード例 #4
0
ファイル: Table.cs プロジェクト: storyteller/Storyteller
 protected internal override void configureSampleStep(Step step)
 {
     var section = findSection(step);
     for (int i = 0; i < 3; i++)
     {
         var row = section.AddStep("row");
         cells.Each(x => x.AddSampleValue(row));
     }
 }
コード例 #5
0
        public void step_that_has_collections()
        {
            var step = new Step("Adding");
            var section = step.AddCollection("Numbers");
            section.AddComment("foo!");
            section.AddComment("bar!");

            Debug.WriteLine(step.ToJson());
        }
コード例 #6
0
ファイル: Step.cs プロジェクト: storyteller/Storyteller
        public void AssertValuesMatch(Step other)
        {
            if (other.Values.Count != Values.Count) throwValuesDoNotMatch(other);

            string[] otherKeys = other.Values.Keys.OrderBy(x => x).ToArray();
            string[] keys = Values.Keys.OrderBy(x => x).ToArray();
            if (!otherKeys.SequenceEqual(keys)) throwValuesDoNotMatch(other);

            other.Values.Keys.Each(key => { if (other.Values[key] != Values[key]) throwValuesDoNotMatch(other); });
        }
コード例 #7
0
ファイル: StepTester.cs プロジェクト: storyteller/Storyteller
        public void validate_cells_happy_path_totally_empty()
        {
            var step = new Step("Something");

            var validator = Substitute.For<IStepValidator>();

            step.ProcessCells(new Cell[0], validator);

            validator.DidNotReceiveWithAnyArgs().AddError(null);
        }
コード例 #8
0
        protected internal override void configureSampleStep(Step step)
        {
            if (collection.IsEmpty())
            {
                collection = fixture.key;
            }

            var section = step.Collections[collection];

            fixture.CreateSampleSteps(section);
        }
コード例 #9
0
        public void create_plan()
        {
            Action<ISpecContext> action = c => { };
            var grammar = new SilentGrammar(2, action);
            var step = new Step("foo");

            var plan = grammar.CreatePlan(step, new FixtureLibrary()).ShouldBeOfType<SilentAction>();

            plan.Position.ShouldBe(2);
            plan.Action.ShouldBeTheSameAs(action);
            plan.Node.ShouldBeTheSameAs(step);
        }
コード例 #10
0
ファイル: StepTester.cs プロジェクト: storyteller/Storyteller
        public void validate_with_a_missing_cell()
        {
            var step = new Step("Something");
            step.Values["A"] = "1";
            step.Values["C"] = "3";

            var cells = new Cell[] { Cell.For<string>("A"), Cell.For<string>("B"), Cell.For<string>("C") };

            var validator = Substitute.For<IStepValidator>();

            step.ProcessCells(cells, validator);

            validator.Received().AddError("Missing value for 'B'");

        }
コード例 #11
0
        public Step ToSampleStep()
        {
            var step = new Step(key);

            if (this is IModelWithCells)
            {
                var cells = this.As<IModelWithCells>().cells ?? new Cell[0];
                foreach (var cell in cells)
                {
                    cell.AddSampleValue(step);
                }
            }

            configureSampleStep(step);

            return step;
        }
コード例 #12
0
ファイル: StepTester.cs プロジェクト: storyteller/Storyteller
        public void move_over_staged_cells_with_some_missing()
        {
            var step = new Step("Something");
            step.StagedValues = new string[] { "1", "2" };

            var cells = new Cell[] { Cell.For<string>("A"), Cell.For<string>("B"), Cell.For<string>("C") };

            var validator = Substitute.For<IStepValidator>();

            step.ProcessCells(cells, validator);


            step.Values["A"].ShouldBe("1");
            step.Values["B"].ShouldBe("2");
            step.Values.ContainsKey("C").ShouldBeFalse();

            validator.Received().AddError("Missing value for 'C'");
        }
コード例 #13
0
ファイル: StepTester.cs プロジェクト: storyteller/Storyteller
        public void move_over_staged_cells()
        {
            var step = new Step("Something");
            step.StagedValues = new string[] {"1", "2", "3"};

            var cells = new Cell[] {Cell.For<string>("A"), Cell.For<string>("B"), Cell.For<string>("C")};

            var validator = Substitute.For<IStepValidator>();

            step.ProcessCells(cells, validator);

            validator.DidNotReceiveWithAnyArgs().AddError(null);


            step.Values["A"].ShouldBe("1");
            step.Values["B"].ShouldBe("2");
            step.Values["C"].ShouldBe("3");
        }
コード例 #14
0
        public IExecutionStep CreatePlan(Step step, FixtureLibrary library, bool inTable = false)
        {
            var section = step
                .Collections[_leafName];

            var expected = section
                .Children.OfType<Step>()
                .Select(row => _cells.ToStepValues(row))
                .ToArray();

            var matcher = _ordered ? OrderedSetMatcher.Flyweight : UnorderedSetMatcher.Flyweight;

            if (section.id.IsEmpty())
            {
                section.id = Guid.NewGuid().ToString();
            }

            return new VerificationSetPlan(section, matcher, _comparison, expected, _cells);
        }
        public void persist_collection_sections_within_a_step()
        {
            var step = new Step("Adding");
            step.AddCollection("Numbers").AddComment("I'm in numbers");
            step.AddCollection("Letters").AddComment("I'm in letters");

            original.AddSection("Math").Children.Add(step);

            var persistedStep = persisted
                .Children.Single().ShouldBeOfType<Section>()
                .Children.Single().ShouldBeOfType<Step>();

            persistedStep.Collections["Numbers"].Children
                .Single().ShouldBeOfType<Comment>()
                .Text.ShouldBe("I'm in numbers");

            persistedStep.Collections["Letters"].Children
                .Single().ShouldBeOfType<Comment>()
                .Text.ShouldBe("I'm in letters");
        }
コード例 #16
0
        public IExecutionStep CreatePlan(Step step, FixtureLibrary library, bool inTable = false)
        {
            var stepValues = _cells.ToStepValues(step);

            return new LineStep(stepValues, this);
        }
コード例 #17
0
 IExecutionStep IGrammar.CreatePlan(Step step, FixtureLibrary library, bool inTable = false)
 {
     return new InvalidGrammarStep(new StepValues(step.id), _message);
 }
コード例 #18
0
 private Section findSection(Step step)
 {
     return(step.Collections[collection]);
 }
コード例 #19
0
 public IExecutionStep CreatePlan(Step step, FixtureLibrary library, bool inTable = false)
 {
     _defaults.Each(pair => step.Values[pair.Key] = pair.Value);
     return _inner.CreatePlan(step, library);
 }
コード例 #20
0
 public IExecutionStep CreatePlan(Step step, FixtureLibrary library, bool inTable = false)
 {
     return _inner.CreatePlan(step, library);
 }
コード例 #21
0
ファイル: FixtureTester.cs プロジェクト: aabenoja/Storyteller
 public IExecutionStep CreatePlan(Step step, FixtureLibrary library)
 {
     throw new NotImplementedException();
 }
コード例 #22
0
ファイル: Table.cs プロジェクト: storyteller/Storyteller
        public override void PostProcessAndValidate(IStepValidator stepValidator, Step step)
        {
            if (!step.Collections.Has(collection))
            {
                if (step.Collections.Count == 1)
                {
                    var clone = step.Collections.Single().CloneAs(collection);
                    step.Collections[collection] = clone;
                }
            }

            var section = findSection(step);
            if (section == null)
            {
                stepValidator.AddError("Missing step collection");
                return;
            }

            stepValidator.Start(section, null);

            var i = 0;
            foreach (var child in section.Children.OfType<Step>())
            {
                i++;
                stepValidator.Start(i, child);

                child.ProcessCells(cells, stepValidator);

                stepValidator.End(child);
            }

            stepValidator.End(section);
        }
コード例 #23
0
ファイル: FactPlan.cs プロジェクト: storyteller/Storyteller
 IExecutionStep IGrammar.CreatePlan(Step step, FixtureLibrary library, bool inTable = false)
 {
     return new FactPlan(new StepValues(step.id), this);
 }
コード例 #24
0
ファイル: Step.cs プロジェクト: storyteller/Storyteller
 private void throwValuesDoNotMatch(Step other)
 {
     throw new Exception("Step values do not match. \n  1st --> {0}\n  2nd --> {1}".ToFormat(ToValueString(),
         other.ToValueString()));
 }
コード例 #25
0
ファイル: Table.cs プロジェクト: storyteller/Storyteller
 private Section findSection(Step step)
 {
     return step.Collections[collection];
 }
コード例 #26
0
ファイル: Step.cs プロジェクト: storyteller/Storyteller
        public static Step Parse(string text)
        {
            var line = text.Trim().Substring(2).Trim();
            var tokens = line.Tokenize().ToArray();

            var key = tokens[0];
            Step step = null;
            if (key.Contains("#"))
            {
                var parts = key.ToDelimitedArray('#');
                step = new Step(parts[0])
                {
                    id = parts[1]
                };
            }
            else
            {
                step = new Step(key);
            }

            var valueIndex = line.IndexOf(key) + key.Length;
            var valueText = line.Substring(valueIndex);

            var values = valueText.ToDelimitedArray();
            if (!values.Any()) return step;

            if (values.All(x => x.Contains("=")))
            {
                foreach (var value in values)
                {
                    var parts = value.TrimEnd(',').ToDelimitedArray('=');
                    step.Values.Add(parts[0], parts[1]);
                }
            }
            else
            {
                step.StagedValues = values;
            }

            return step;
        }
コード例 #27
0
 public IExecutionStep CreatePlan(Step step, FixtureLibrary library)
 {
     return new CompositeExecution(toExecutionSteps(library, step));
 }
コード例 #28
0
        private IEnumerable<IExecutionStep> toExecutionSteps(FixtureLibrary library, Step parentStep)
        {
            Section section = parentStep.Collections[_leafName];
            if (section.id.IsEmpty()) section.id = Guid.NewGuid().ToString();

            if (_before != null) yield return new SilentAction("Grammar", Stage.before, _before, section)
            {
                Subject = Key + "Before"
            };

            foreach (Step row in section.Children.OfType<Step>())
            {
                yield return _inner.CreatePlan(row, library);
            }

            if (_after != null) yield return new SilentAction("Grammar", Stage.after, _after, section)
            {
                Subject = Key + ":After"
            };
        }
コード例 #29
0
 public IExecutionStep CreatePlan(Step step, FixtureLibrary library)
 {
     var innerPlan = _inner.CreatePlan(step, library);
     return new ImportedExecutionStep(_innerFixture, innerPlan);
 }
        public void read_and_write_a_step_with_plain_values_under_a_section()
        {
            var step = new Step("Add").With("x", "1").With("y", "2").With("sum", "3");
            step.id = Guid.NewGuid().ToString();

            var section = new Section("Math");
            section.Children.Add(step);

            original.Children.Add(section);

            var persistedStep = persisted.Children.Single()
                .ShouldBeOfType<Section>().Children
                .Single().ShouldBeOfType<Step>();

            persistedStep.AssertValuesMatch(step);
        }
コード例 #31
0
 public IExecutionStep CreatePlan(Step step, FixtureLibrary library)
 {
     return _inner.CreatePlan(step, library);
 }
コード例 #32
0
ファイル: ErrorGrammar.cs プロジェクト: jawn/Storyteller
 public IExecutionStep CreatePlan(Step step, FixtureLibrary library)
 {
     return(new InvalidGrammarStep(new StepValues(step.id), _message));
 }