public void CreatesNewInstanceEachTime()
        {
            var container = new SimpleContainer();

            var policy    = new TransientLifetimePolicy(typeof(ExampleClass), container);
            var instance1 = policy.GetInstance();
            var instance2 = policy.GetInstance();

            Assert.AreNotEqual(instance1, instance2);
            Assert.IsTrue(instance1 is ExampleClass);
            Assert.IsTrue(instance2 is ExampleClass);
        }
        public void DealsWithDependencies()
        {
            var dependencyInstance = new Dependency();
            var container          = new SimpleContainer();

            container.RegisterInstance <Dependency>(dependencyInstance);

            var policy   = new TransientLifetimePolicy(typeof(Target), container);
            var instance = policy.GetInstance() as Target;

            Assert.IsNotNull(instance);
            Assert.AreEqual(dependencyInstance, instance.Dependency);
        }
        private void RegisterType(bool singleton, Type type)
        {
            ILifetimePolicy policy = null;

            if (singleton)
            {
                policy = new SingletonLifetimePolicy(type, this);
            }
            else
            {
                policy = new TransientLifetimePolicy(type, this);
            }

            _resolvers[type] = new ConcreteTypeResolver(policy);
        }