public void TestDisposeAll() { try { ListUtils.DisposeAll(null); Assert.Fail(); } catch (Exception e) { Assert.IsInstanceOfType(e, typeof(ArgumentNullException)); Assert.AreEqual((e as ArgumentException).ParamName, "values"); } try { ListUtils.DisposeAll(new List <int> { 1, 2, 3 }); } catch (Exception e) { Assert.IsInstanceOfType(e, typeof(InvalidCastException)); } var obj = new DisposableObj(); var list = new List <IDisposable> { obj }; ListUtils.DisposeAll(list); Assert.IsTrue(obj.isDisposed); Assert.IsFalse(obj.wasDisposedMoreThanOnce); }