-Refactor ExceptionAssert

This commit is contained in:
James Newton-King
2014-09-12 21:33:53 +12:00
parent 4b9ce67ab7
commit dfb2ac17a5
43 changed files with 979 additions and 1482 deletions
+1 -21
View File
@@ -196,26 +196,6 @@ namespace Newtonsoft.Json.Tests
public static class ExceptionAssert
{
public static void Throws<TException>(string message, Action action)
where TException : Exception
{
try
{
action();
Assert.Fail("Exception of type {0} expected; got none exception", typeof(TException).Name);
}
catch (TException ex)
{
if (message != null)
Assert.AreEqual(message, ex.Message, "Unexpected exception message." + Environment.NewLine + "Expected: " + message + Environment.NewLine + "Got: " + ex.Message + Environment.NewLine + Environment.NewLine + ex);
}
catch (Exception ex)
{
throw new Exception(string.Format("Exception of type {0} expected; got exception of type {1}.", typeof(TException).Name, ex.GetType().Name), ex);
}
}
public static void Throws<TException>(Action action, params string[] possibleMessages)
where TException : Exception
{
@@ -223,7 +203,7 @@ namespace Newtonsoft.Json.Tests
{
action();
Assert.Fail("Exception of type {0} expected; got none exception", typeof(TException).Name);
Assert.Fail("Exception of type {0} expected. No exception thrown.", typeof(TException).Name);
}
catch (TException ex)
{