예제 #1
0
        public void ResolveAllUnregisteredTypeReturnsEmptyCollection()
        {
            var ioc = new MicroIocContainer();

            var instances = ioc.ResolveAll(typeof(Foo));

            Assert.IsNotNull(instances);
            Assert.AreEqual(0, instances.Count());
        }
예제 #2
0
        public void ResolveAllReturnsSingleRegisteredTypeInACollection()
        {
            var ioc = new MicroIocContainer()
                      .Register <IFoo, Foo>();

            var instances = ioc.ResolveAll(typeof(IFoo));

            Assert.IsNotNull(instances);
            Assert.AreEqual(1, instances.Count());
            Assert.IsInstanceOfType(instances.Single(), typeof(IFoo), "Registered instance should be an IFoo");
        }
예제 #3
0
        public void ResolveAllReturnsAllRegisteredTypesInACollection()
        {
            var ioc = new MicroIocContainer()
                      .Register <IFoo, Foo>("One")
                      .RegisterInstance <IFoo>(new Foo(), "Two")
                      .Register <IFoo, Foo>("Three", true);

            var instances = ioc.ResolveAll(typeof(IFoo));

            Assert.IsNotNull(instances);
            Assert.AreEqual(3, instances.Count());
        }
예제 #4
0
        public void ResolveAllUnregisteredTypeReturnsEmptyCollection()
        {
            var ioc = new MicroIocContainer();

            var instances = ioc.ResolveAll(typeof (Foo));

            Assert.IsNotNull(instances);
            Assert.AreEqual(0, instances.Count());
        }
예제 #5
0
        public void ResolveAllReturnsSingleRegisteredTypeInACollection()
        {
            var ioc = new MicroIocContainer()
                .Register<IFoo, Foo>();

            var instances = ioc.ResolveAll(typeof(IFoo));

            Assert.IsNotNull(instances);
            Assert.AreEqual(1, instances.Count());
            Assert.IsInstanceOfType(instances.Single(), typeof(IFoo), "Registered instance should be an IFoo");
        }
예제 #6
0
        public void ResolveAllReturnsAllRegisteredTypesInACollection()
        {
            var ioc = new MicroIocContainer()
                .Register<IFoo, Foo>("One")
                .RegisterInstance<IFoo>(new Foo(), "Two")
                .Register<IFoo, Foo>("Three", true);

            var instances = ioc.ResolveAll(typeof(IFoo));

            Assert.IsNotNull(instances);
            Assert.AreEqual(3, instances.Count());
        }