Added Exception.Throws overload to take multiple possible messages to match

This way tests can pass in multiple possible string matches which the runtime may use as a message depending on the given platform (e.g.: MS-Runtime vs Mono)
This commit is contained in:
Redth
2014-09-09 09:39:05 -04:00
parent aa6c474999
commit 831e32809e
5 changed files with 77 additions and 34 deletions
@@ -2975,8 +2975,11 @@ Path '', line 1, position 1.",
string json = @"[]";
ExceptionAssert.Throws<InvalidCastException>(
@"Unable to cast object of type 'Newtonsoft.Json.Linq.JArray' to type 'Newtonsoft.Json.Linq.JObject'.",
() => { JsonConvert.DeserializeObject<JObject>(json); });
() => { JsonConvert.DeserializeObject<JObject>(json); },
new [] {
"Unable to cast object of type 'Newtonsoft.Json.Linq.JArray' to type 'Newtonsoft.Json.Linq.JObject'.",
"Cannot cast from source type to destination type." // mono
});
}
[Test]
@@ -6304,18 +6307,22 @@ To fix this error either change the environment to be fully trusted, change the
public void DeserializeDoubleFromNullString()
{
ExceptionAssert.Throws<ArgumentNullException>(
@"Value cannot be null.
Parameter name: value",
() => { JsonConvert.DeserializeObject<double>(null); });
() => { JsonConvert.DeserializeObject<double>(null); },
new [] {
"Value cannot be null." + Environment.NewLine + "Parameter name: value",
"Argument cannot be null." + Environment.NewLine + "Parameter name: value" // mono
});
}
[Test]
public void DeserializeFromNullString()
{
ExceptionAssert.Throws<ArgumentNullException>(
@"Value cannot be null.
Parameter name: value",
() => { JsonConvert.DeserializeObject(null); });
() => { JsonConvert.DeserializeObject(null); },
new [] {
"Value cannot be null." + Environment.NewLine + "Parameter name: value",
"Argument cannot be null." + Environment.NewLine + "Parameter name: value" // mono
});
}
[Test]