public void TransientTypeRegistration()
        {
            ServiceContainer.Register <LifetimeObject>(ServiceLifetime.Transient);
            LifetimeObject result1 = null;
            LifetimeObject result2 = null;
            LifetimeObject result3 = null;
            Thread         thread1 = new Thread(delegate()
            {
                result1 = ServiceContainer.GetInstance <LifetimeObject>();
            });

            Thread thread2 = new Thread(delegate()
            {
                result2 = ServiceContainer.GetInstance <LifetimeObject>();
                result3 = ServiceContainer.GetInstance <LifetimeObject>();
            });

            thread1.Start();
            thread2.Start();

            thread2.Join();
            thread1.Join();

            Assert.NotNull(result1);
            Assert.NotNull(result2);
            Assert.NotNull(result3);
            Assert.NotSame(result1, result2);
            Assert.NotSame(result3, result2);
        }
        public void SingletonTypeRegistration()
        {
            ServiceContainer.Register <LifetimeObject>(ServiceLifetime.Singleton);
            LifetimeObject result1 = ServiceContainer.GetInstance <LifetimeObject>();
            LifetimeObject result2 = ServiceContainer.GetInstance <LifetimeObject>();

            Assert.NotNull(result1);
            Assert.Same(result1, result2);
        }
        public void SingletonInThreads()
        {
            ServiceContainer.Register <LifetimeObject>(ServiceLifetime.Singleton);
            LifetimeObject result1 = null;
            LifetimeObject result2 = null;
            Thread         thread1 = new Thread(delegate()
            {
                result1 = ServiceContainer.GetInstance <LifetimeObject>();
            });

            Thread thread2 = new Thread(delegate()
            {
                result2 = ServiceContainer.GetInstance <LifetimeObject>();
            });

            thread1.Start();
            thread2.Start();

            thread2.Join();
            thread1.Join();

            Assert.NotNull(result1);
            Assert.Same(result1, result2);
        }