using Microsoft.VisualStudio.TestTools.UnitTesting; using System; namespace Tests { internal class AssertEx { internal static void Throws(Action action) where T : Exception { Throws(action, _ => true); } internal static void Throws(Action action, Func assert) where T : Exception { var failed = false; try { action(); } catch (T ex) { Assert.IsTrue(assert(ex)); failed = true; } Assert.IsTrue(failed); } internal static void SucceedOrFailProper(Action action) { try { action(); } catch (AggregateException ex) { var inner = ex.Flatten().InnerException; // TODO: proper assert; unfortunately there's not always a good call stack } } } }