예제 #1
0
        public void RegisterInstanceIsFluent()
        {
            IMicroIocContainer iocContainer = new MicroIocContainer();

            var newContainer = iocContainer.RegisterInstance <IFoo>(new Foo());

            Assert.AreSame(iocContainer, newContainer);
        }
예제 #2
0
        public void RegisteringSubsequentInstancesOfTypeWithSameKeyOverwritesPrevious()
        {
            const string key  = "fooKey"; // Nell
            var          foo1 = new Foo();
            var          foo2 = new Foo();

            var iocContainer = new MicroIocContainer()
                               .RegisterInstance <IFoo>(foo1, key);

            Assert.AreSame(foo1, iocContainer.Resolve <IFoo>(key));

            iocContainer.RegisterInstance <IFoo>(foo2, key);

            Assert.AreSame(foo2, iocContainer.Resolve <IFoo>(key));
        }
예제 #3
0
        public void RegisterInstanceIsFluent()
        {
            IMicroIocContainer iocContainer = new MicroIocContainer();

            var newContainer = iocContainer.RegisterInstance<IFoo>(new Foo());

            Assert.AreSame(iocContainer, newContainer);
        }
예제 #4
0
        public void RegisteringSubsequentInstancesOfTypeWithSameKeyOverwritesPrevious()
        {
            const string key = "fooKey"; // Nell
            var foo1 = new Foo();
            var foo2 = new Foo();

            var iocContainer = new MicroIocContainer()
                .RegisterInstance<IFoo>(foo1, key);

            Assert.AreSame(foo1, iocContainer.Resolve<IFoo>(key));

            iocContainer.RegisterInstance<IFoo>(foo2, key);

            Assert.AreSame(foo2, iocContainer.Resolve<IFoo>(key));
        }