public void TestRemoveInstance()
 {
     ContainerManagedLifetimeManager manager = new ContainerManagedLifetimeManager();
       object o = new object();
       manager.AddInstance(o);
       manager.RemoveInstance();
       Assert.IsNull(manager.GetInstance());
       Mock<IDisposable> disposable = new Mock<IDisposable>();
       manager.AddInstance(disposable.Object);
       manager.RemoveInstance();
       disposable.Verify(p => p.Dispose(), Times.Exactly(1));
 }
 public void TestObjectDisposed()
 {
     ContainerManagedLifetimeManager manager = new ContainerManagedLifetimeManager();
       manager.Dispose();
       try
       {
     manager.AddInstance(new object());
     Assert.Fail();
       }
       catch (ObjectDisposedException)
       { }
       try
       {
     manager.GetInstance();
     Assert.Fail();
       }
       catch (ObjectDisposedException)
       { }
       try
       {
     manager.RemoveInstance();
     Assert.Fail();
       }
       catch (ObjectDisposedException)
       { }
       try
       {
     manager.Dispose();
     Assert.Fail();
       }
       catch (ObjectDisposedException)
       { }
 }
 public void TestAddRetrieve()
 {
     ContainerManagedLifetimeManager manager = new ContainerManagedLifetimeManager();
       object o = new object();
       manager.AddInstance(o);
       Assert.AreEqual(o, manager.GetInstance());
 }
 public void TestDispose()
 {
     ContainerManagedLifetimeManager manager = new ContainerManagedLifetimeManager();
       Mock<IDisposable> disposable = new Mock<IDisposable>();
       manager.AddInstance(disposable.Object);
       manager.Dispose();
       disposable.Verify(p => p.Dispose(), Times.Exactly(1));
 }