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

            var newContainer = iocContainer.Register <IFoo>(typeof(Foo));

            Assert.AreSame(iocContainer, newContainer);
        }
예제 #2
0
        public void RegisterIsFluent()
        {
            IMicroIocContainer iocContainer = new MicroIocContainer();

            var newContainer = iocContainer.Register <IFoo, Foo>();

            Assert.AreSame(iocContainer, newContainer);
        }
예제 #3
0
        public void RegisteringSubsequentImplentationTypesOverwritesPrevious()
        {
            var iocContainer = new MicroIocContainer()
                               .Register <IFoo, Foo>();

            Assert.IsInstanceOfType(iocContainer.Resolve <IFoo>(), typeof(Foo));

            iocContainer.Register <IFoo, Foo2>();
            Assert.IsInstanceOfType(iocContainer.Resolve <IFoo>(), typeof(Foo2));
        }
예제 #4
0
        public void CanRegisterWithoutExceptions()
        {
            var threw = false;

            try
            {
                var iocContainer = new MicroIocContainer();
                iocContainer.Register <IFoo, Foo>();
            }
            catch (Exception)
            {
                threw = true;
            }
            finally
            {
                Assert.IsFalse(threw, "Failed to register without an exception");
            }
        }
예제 #5
0
        public void CanRegisterWithoutExceptions()
        {
            var threw = false;

            try
            {
                var iocContainer = new MicroIocContainer();
                iocContainer.Register<IFoo, Foo>();
            }
            catch (Exception)
            {
                threw = true;
            }
            finally
            {
                Assert.IsFalse(threw, "Failed to register without an exception");
            }
        }
예제 #6
0
        public void CanRegisterByType()
        {
            IMicroIocContainer iocContainer = new MicroIocContainer();

            var newContainer = iocContainer.Register<IFoo>(typeof(Foo));

            Assert.AreSame(iocContainer, newContainer);
        }
예제 #7
0
        public void RegisterIsFluent()
        {
            IMicroIocContainer iocContainer = new MicroIocContainer();

            var newContainer = iocContainer.Register<IFoo, Foo>();

            Assert.AreSame(iocContainer, newContainer);
        }
예제 #8
0
        public void RegisteringSubsequentImplentationTypesOverwritesPrevious()
        {
            var iocContainer = new MicroIocContainer()
                .Register<IFoo, Foo>();
            Assert.IsInstanceOfType(iocContainer.Resolve<IFoo>(), typeof(Foo));

            iocContainer.Register<IFoo, Foo2>();
            Assert.IsInstanceOfType(iocContainer.Resolve<IFoo>(), typeof(Foo2));
        }