using System; using System.Collections.Generic; using System.Linq; using System.Text; using NUnit.Framework; namespace Developpez.Dotnet.Tests { public class Assert2 { public static void Throws(Action action) where TException : Exception { Throws(action, null); } public static void Throws(Action action, Func exceptionPredicate) where TException : Exception { bool wasRaised = false; try { action(); } catch (TException ex) { wasRaised = true; if (exceptionPredicate != null) Assert.IsTrue(exceptionPredicate(ex)); } Assert.IsTrue(wasRaised, "A '{0}' was expected but was not thrown.", typeof(TException).Name); } public static void AreSequenceEqual(IEnumerable expected, IEnumerable actual) { Assert.IsTrue(expected.SequenceEqual(actual)); } public static void AreSequenceEqual(IEnumerable expected, IEnumerable actual, Func keySelector) { Assert.IsTrue(expected.OrderBy(keySelector).SequenceEqual(actual.OrderBy(keySelector))); } } }