Skip to content

Instantly share code, notes, and snippets.

@jbosse
Created March 22, 2010 19:10
Show Gist options
  • Save jbosse/340410 to your computer and use it in GitHub Desktop.
Save jbosse/340410 to your computer and use it in GitHub Desktop.
[Test]
public virtual void ShouldAllReturnHello()
{
AssertAll
(
() => Assert.AreEqual("Hello", "World"),
() => Assert.AreEqual("Hello", "Kevin"),
() => Assert.AreEqual("Hello", "Jimmy"),
() => Assert.AreEqual("Hello", "Hello")
);
}
[System.Diagnostics.DebuggerHidden]
[System.Diagnostics.DebuggerNonUserCode]
[System.Diagnostics.DebuggerStepperBoundary]
private void AssertAll(params Action[] asserts)
{
List<Exception> exs = new List<Exception>();
foreach (var action in asserts)
{
try
{
action();
}
catch (AssertionException ae)
{
exs.Add(ae);
}
}
if (exs.Count < 1)
{
return;
}
StringBuilder sb = new StringBuilder();
foreach (var exception in exs)
{
sb.AppendLine(exception.ToString());
sb.AppendLine();
}
throw new AssertionException(sb.ToString());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment