public void add_many_and_range()
        {
            var list = new List<string>();
            list.AddMany("a", "b", "c");

            list.ShouldHaveTheSameElementsAs("a", "b", "c");
        }
        public void AutomaticallyFindRegistryFromAssembly()
        {
            var container = new Container(x =>
            {
                x.Scan(s =>
                {
                    s.AssemblyContainingType<RedGreenRegistry>();
                    s.LookForRegistries();
                });
            });

            var colors = new List<string>();
            foreach (var widget in container.GetAllInstances<IWidget>())
            {
                if (!(widget is ColorWidget))
                {
                    continue;
                }

                var color = (ColorWidget)widget;
                colors.Add(color.Color);
            }

            colors.Sort();
            colors.ShouldHaveTheSameElementsAs("Black", "Blue", "Brown", "Green", "Red", "Yellow");
        }
Example #3
0
        public void on_addition_should_fire_when_a_cache_adds_something_from_its_on_missing_catch()
        {
            var list = new List<int>();
            int x = 0;

            cache.OnMissing = key => ++x;

            cache.OnAddition = number => list.Add(number);

            cache["a"] = 100;
            cache["b"].ShouldBe(1);
            cache["c"].ShouldBe(2);

            list.ShouldHaveTheSameElementsAs(100, 1, 2);
        }