상속: 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
        public Step AddStep(string key)
        {
            var step = new Step(key);
            Children.Add(step);

            return step;
        }
예제 #4
0
 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));
     }
 }
        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
        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
        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);
        }
        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
        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
        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
        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");
        }
        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);
 }
 public IExecutionStep CreatePlan(Step step, FixtureLibrary library, bool inTable = false)
 {
     return _inner.CreatePlan(step, library);
 }
예제 #21
0
 public IExecutionStep CreatePlan(Step step, FixtureLibrary library)
 {
     throw new NotImplementedException();
 }
예제 #22
0
        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
 IExecutionStep IGrammar.CreatePlan(Step step, FixtureLibrary library, bool inTable = false)
 {
     return new FactPlan(new StepValues(step.id), this);
 }
예제 #24
0
 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
 private Section findSection(Step step)
 {
     return step.Collections[collection];
 }
예제 #26
0
        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);
        }
 public IExecutionStep CreatePlan(Step step, FixtureLibrary library)
 {
     return _inner.CreatePlan(step, library);
 }
예제 #32
0
 public IExecutionStep CreatePlan(Step step, FixtureLibrary library)
 {
     return(new InvalidGrammarStep(new StepValues(step.id), _message));
 }