Ejemplo n.º 1
0
        public void AddInstanceFromContainer()
        {
            var one       = new SomethingOne();
            var container = new Container();

            container.Inject <ISomething>(one);

            one.ShouldBeTheSameAs(container.GetInstance <ISomething>());
        }
Ejemplo n.º 2
0
        public void OverwriteInstanceFromObjectFactory()
        {
            var one       = new SomethingOne();
            var two       = new SomethingOne();
            var container = new Container();

            container.Inject <ISomething>(one);
            container.Inject <ISomething>(two);

            two.ShouldBeTheSameAs(container.GetInstance <ISomething>());
        }
Ejemplo n.º 3
0
        public void AddNamedInstanceToobjectFactory()
        {
            var one = new SomethingOne();
            var two = new SomethingOne();

            var container = new Container(r =>
            {
                r.For <ISomething>().AddInstances(x =>
                {
                    x.Object(one).Named("One");
                    x.Object(two).Named("Two");
                });
            });

            one.ShouldBeTheSameAs(container.GetInstance <ISomething>("One"));
            two.ShouldBeTheSameAs(container.GetInstance <ISomething>("Two"));
        }