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 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)); }