Exemple #1
0
        public void RegisterInstance()
        {
            INDOContainer container = new NDOContainer();

            var car1 = new BMW();

            container.RegisterInstance <ICar>(car1);

            var car2 = container.Resolve <ICar>();

            Assert.AreSame(car1, car2);
        }
Exemple #2
0
        public void RegisterInstanceWithName()
        {
            INDOContainer container = new NDOContainer();

            var bmw1 = new BMW();

            container.RegisterInstance <ICar>(bmw1, "bmw");
            var audi1 = new Audi();

            container.RegisterInstance <ICar>(audi1, "audi");

            var bmw2 = container.Resolve <ICar>("bmw");

            Assert.AreSame(bmw1, bmw2);
            var audi2 = container.Resolve <ICar>("audi");

            Assert.AreSame(audi1, audi2);
        }