Esempio n. 1
0
 public void MyIocContainerShouldReturnTheSameInstanceOfSingletonTypes()
 {
     MyIocContainer ioc = new MyIocContainer();
     ioc.Register<ISimpleService, SimpleWorker>(LifeCycleTypes.SINGLETON);
     var worker0 = ioc.Resolve(typeof(ISimpleService));
     var worker1 = ioc.Resolve(typeof(ISimpleService));
     Assert.AreEqual(worker0, worker1);
 }
Esempio n. 2
0
 public void MyIocContainerShouldReturnNewInstancesOfTransientTypes()
 {
     MyIocContainer ioc = new MyIocContainer();
     ioc.Register<ISimpleService, SimpleWorker>();
     var worker0 = ioc.Resolve(typeof(ISimpleService));
     var worker1 = ioc.Resolve(typeof(ISimpleService));
     Assert.AreNotEqual(worker0, worker1);
 }
Esempio n. 3
0
        public void MyIocContainerShouldReturnTheSameInstanceOfSingletonTypes()
        {
            MyIocContainer ioc = new MyIocContainer();

            ioc.Register <ISimpleService, SimpleWorker>(LifeCycleTypes.SINGLETON);
            var worker0 = ioc.Resolve(typeof(ISimpleService));
            var worker1 = ioc.Resolve(typeof(ISimpleService));

            Assert.AreEqual(worker0, worker1);
        }
Esempio n. 4
0
        public void MyIocContainerShouldReturnNewInstancesOfTransientTypes()
        {
            MyIocContainer ioc = new MyIocContainer();

            ioc.Register <ISimpleService, SimpleWorker>();
            var worker0 = ioc.Resolve(typeof(ISimpleService));
            var worker1 = ioc.Resolve(typeof(ISimpleService));

            Assert.AreNotEqual(worker0, worker1);
        }
Esempio n. 5
0
 public void MyIocContainerShouldResolveADependency()
 {
     MyIocContainer ioc = new MyIocContainer();
     ioc.Register<ISimpleService, SimpleWorker>();
     var worker = ioc.Resolve(typeof(ISimpleService));
     Assert.AreEqual(typeof(SimpleWorker), worker.GetType());
 }
Esempio n. 6
0
        public void MyIocContainerShouldResolveADependency()
        {
            MyIocContainer ioc = new MyIocContainer();

            ioc.Register <ISimpleService, SimpleWorker>();
            var worker = ioc.Resolve(typeof(ISimpleService));

            Assert.AreEqual(typeof(SimpleWorker), worker.GetType());
        }
Esempio n. 7
0
 public void MyIocContainerShouldResolveNestedDependencies()
 {
     MyIocContainer ioc = new MyIocContainer();
     ioc.Register<ISimpleService, SimpleWorker>();
     ioc.Register<IComplexService, ComplexWorker>();
     var complexWorker = ioc.Resolve(typeof(IComplexService));
     Assert.AreEqual(typeof(ComplexWorker), complexWorker.GetType());
     Assert.AreEqual(typeof(SimpleWorker), (complexWorker as ComplexWorker).NestedSimpleService.GetType());
 }
Esempio n. 8
0
        public void MyIocContainerShouldResolveNestedDependencies()
        {
            MyIocContainer ioc = new MyIocContainer();

            ioc.Register <ISimpleService, SimpleWorker>();
            ioc.Register <IComplexService, ComplexWorker>();
            var complexWorker = ioc.Resolve(typeof(IComplexService));

            Assert.AreEqual(typeof(ComplexWorker), complexWorker.GetType());
            Assert.AreEqual(typeof(SimpleWorker), (complexWorker as ComplexWorker).NestedSimpleService.GetType());
        }