public void CanSetDefaultLifetimeManagerToThreadLocalStorageLifetime()
        {
            var lifetime = new ThreadLocalStorageLifetime();
            iocContainer.UsesDefaultLifetimeManagerOf(lifetime);

            Verify.That(iocContainer.DefaultLifetimeManager).IsTheSameObjectAs(lifetime);
        }
 public void ShouldResolveGenerics()
 {
     var lifetime = new ThreadLocalStorageLifetime();
     using (var container = new Munq.IocContainer())
     {
         container.Register<IFoo<int>, Foo<int>>().WithLifetimeManager(lifetime);
         container.Register<IFoo<string>, Foo<string>>().WithLifetimeManager(lifetime);
         Assert.IsNotNull(container.Resolve<IFoo<int>>());
         // works
         Assert.IsNotNull(container.Resolve<IFoo<string>>());
     }  // fails
 }
 public void ThreadLocalStorageLifetimeManagerReturnsSameObjectForSameRequest()
 {
     var requestltm = new ThreadLocalStorageLifetime();
     using (var container = new IocContainer())
     {
         container.Register<IFoo>(c => new Foo1()).WithLifetimeManager(requestltm);
         IFoo result1 = container.Resolve<IFoo>();
         IFoo result2 = container.Resolve<IFoo>();
         IFoo result3 = null;
         IFoo result4 = null;
         // get values on a different thread
         var t = Task.Factory.StartNew(() =>
         {
             result3 = container.Resolve<IFoo>();
             result4 = container.Resolve<IFoo>();
         });
         t.Wait();
         // check the results
         Verify.That(result3).IsNotNull();
         Verify.That(result4).IsNotNull().IsTheSameObjectAs(result3);
         Verify.That(result2).IsNotNull();
         Verify.That(result1).IsNotNull().IsTheSameObjectAs(result2).IsNotTheSameObjectAs(result3);
     }
 }