public void TryDispose_DisposesItemsInNonGenericEnumerable() { var list = new System.Collections.ArrayList(); var t = new TestDisposable(); var t1 = new TestDisposable(); list.Add(t); list.Add(t1); list.TryDispose(); Assert.IsTrue(t.IsDisposed); Assert.IsTrue(t1.IsDisposed); }
public void IEnumerable_TryDispose_DisposesAllITems() { var list = new System.Collections.ArrayList(); for (int cnt = 0; cnt < 5; cnt++) { list.Add(new TestDisposable()); } list.TryDispose(DisposeOptions.None); foreach (var item in list) { Assert.IsTrue((((IIsDisposed)item).IsDisposed)); } }
public void TryDispose_IgnoresNullNonGenericEnumerable() { System.Collections.ArrayList list = null; list.TryDispose(); }