Example #1
0
        public void copies_grammars()
        {
            const string fixtureKey = "a key";

            var lib      = new FixtureLibrary();
            var original = new FixtureModel(fixtureKey);

            lib.Models[fixtureKey] = original;

            original.AddGrammar(new Sentence {
                key = "sentence", format = "a format"
            });

            var overrides = new FixtureLibrary();
            var overriden = new FixtureModel(fixtureKey);

            overrides.Models[fixtureKey] = overriden;

            var result = lib.ApplyOverrides(overrides);

            result.Models.Count.ShouldBe(1);

            var fixture = result.Models[fixtureKey];

            ReferenceEquals(fixture, overrides.Models[fixtureKey]).ShouldBeFalse();
            fixture.key.ShouldBe(fixtureKey);

            fixture.grammars.Length.ShouldBe(1);

            var sentence = fixture.grammars[0] as Sentence;

            sentence.key.ShouldBe("sentence");
            sentence.format.ShouldBe("a format");
        }
Example #2
0
        public void overrides_original_title()
        {
            const string key = "a key";

            var lib      = new FixtureLibrary();
            var original = new FixtureModel(key);

            original.title          = "A title";
            original.implementation = "some implementation";
            lib.Models[key]         = original;

            var overrides = new FixtureLibrary();
            var overriden = new FixtureModel(key);

            overriden.title       = "A new title";
            overrides.Models[key] = overriden;

            var result = lib.ApplyOverrides(overrides);

            result.Models.Count.ShouldBe(1);

            var fixture = result.Models[key];

            ReferenceEquals(fixture, overrides.Models[key]).ShouldBeFalse();
            fixture.title.ShouldBe(overriden.title);
            fixture.implementation.ShouldBe(original.implementation);
        }
Example #3
0
        public FixtureModel[] CombinedFixtures()
        {
            if (_overrides == null)
            {
                return(_systemFixtures.Models.ToArray());
            }

            return(_systemFixtures.ApplyOverrides(_overrides).Models.ToArray());
        }
        private static FixtureModel[] buildFixturesWithOverrides(RunInput input, SystemRecycled systemRecycled)
        {
            var overrides = FixtureLoader.LoadFromPath(input.FixturePath);
            var system    = new FixtureLibrary();

            foreach (var fixture in systemRecycled.fixtures)
            {
                system.Models[fixture.key] = fixture;
            }

            return(system.ApplyOverrides(overrides).Models.ToArray());
        }
Example #5
0
        internal FixtureModel[] BuildFixturesWithOverrides(SystemRecycled systemRecycled)
        {
            var overrides = FixtureLoader.LoadFromPath(FixturePath);
            var system    = new FixtureLibrary();

            foreach (var fixture in systemRecycled.fixtures)
            {
                system.Models[fixture.key] = fixture;
            }

            return(system.ApplyOverrides(overrides).Models.ToArray());
        }
Example #6
0
        public void tracks_when_a_fixture_is_missing_from_code()
        {
            const string key = "a key";

            var lib = new FixtureLibrary();

            var overrides = new FixtureLibrary();

            overrides.Models[key] = new FixtureModel(key);

            var result = lib.ApplyOverrides(overrides);

            result.Models[key].IsMissing.ShouldBeTrue();
        }
Example #7
0
        public void copies_from_overrides_when_not_in_original()
        {
            const string key = "a key";

            var lib = new FixtureLibrary();

            var overrides = new FixtureLibrary();

            overrides.Models[key] = new FixtureModel(key);

            var result = lib.ApplyOverrides(overrides);

            result.Models.Count.ShouldBe(1);

            var fixture = result.Models[key];

            fixture.key.ShouldBe(key);
        }