Ejemplo n.º 1
0
        public override GrammarModel ApplyOverrides(GrammarModel grammar)
        {
            if (!(grammar is FixtureModel))
            {
                return(this);
            }

            var model = new FixtureModel(key)
            {
                implementation = implementation
            };
            var over = grammar.As <FixtureModel>();

            model.title = over.title.IsNotEmpty() ? over.title : title;

            foreach (var existing in _grammars)
            {
                var overridden = over.FindGrammar(existing.key);
                var combined   = overridden == null ? existing : existing.ApplyOverrides(overridden);
                combined.errors =
                    (existing.errors ?? new GrammarError[0]).Concat((overridden?.errors ?? new GrammarError[0]))
                    .ToArray();

                model.AddGrammar(combined);
            }

            foreach (var specified in over.grammars.Where(x => !grammars.Any(_ => _.key == x.key)))
            {
                specified.IsMissing = true;
                model.AddGrammar(specified);
            }

            return(model);
        }
Ejemplo n.º 2
0
        public void ValidateStepsWithinSection(Section section, FixtureModel fixture)
        {
            if (fixture.IsMissing)
            {
                AddError($"Fixture '{fixture.key}' is not implemented");
            }

            var i = 0;

            foreach (var step in section.Children.OfType <Step>())
            {
                i++;

                _locations.Push($"Step #{i}: {step.Key}");

                var grammar = fixture.FindGrammar(step.Key);
                if (grammar == null)
                {
                    AddError($"Unknown Grammar '{step.Key}'");
                }
                else
                {
                    if (grammar.IsMissing)
                    {
                        AddError($"Grammar '{step.Key}' is not implemented");
                    }

                    grammar.PostProcessAndValidate(this, step);
                }

                _locations.Pop();
            }
        }
Ejemplo n.º 3
0
        public override void ResolveDependencies(FixtureLibrary library)
        {
            var embeddedKey = fixture.key;

            if (library.Models.Has(embeddedKey))
            {
                fixture = library.Models[embeddedKey];
            }
        }
Ejemplo n.º 4
0
 void IStepValidator.Start(Section section, FixtureModel fixture)
 {
     if (fixture == null)
     {
         _locations.Push($"Collection '{section.Key}'");
     }
     else
     {
         _locations.Push($"Collection '{section.Key}' using Fixture '{fixture.key}'");
     }
 }
Ejemplo n.º 5
0
        public void ApplyFixtureOverrides(FixtureLibrary systemLibrary, FixtureLibrary overrides)
        {
            var embeddedKey = fixture.key;

            if (systemLibrary.Models.Has(embeddedKey))
            {
                var systemFixture = systemLibrary.Models[embeddedKey];

                fixture = overrides.Models.Has(embeddedKey)
                    ? systemFixture.ApplyOverrides(overrides.Models[embeddedKey]).As <FixtureModel>()
                    : systemFixture;
            }
            else
            {
                fixture = overrides.Models[embeddedKey];
            }

            if (collection.IsEmpty())
            {
                collection = fixture.key;
            }
        }