-Refactor ExceptionAssert
This commit is contained in:
@@ -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)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user