-Refactor ExceptionAssert
This commit is contained in:
@@ -120,8 +120,7 @@ undefined
|
||||
jsonReader.Read();
|
||||
jsonReader.Read();
|
||||
|
||||
ExceptionAssert.Throws<JsonReaderException>(@"Error reading JToken from JsonReader. Unexpected token: EndArray. Path '', line 1, position 2.",
|
||||
() => JToken.ReadFrom(jsonReader));
|
||||
ExceptionAssert.Throws<JsonReaderException>(() => JToken.ReadFrom(jsonReader), @"Error reading JToken from JsonReader. Unexpected token: EndArray. Path '', line 1, position 2.");
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -711,34 +710,31 @@ keyword such as type of business.""
|
||||
[Test]
|
||||
public void JObjectIntIndex()
|
||||
{
|
||||
ExceptionAssert.Throws<ArgumentException>("Accessed JObject values with invalid key value: 0. Object property name expected.",
|
||||
() =>
|
||||
{
|
||||
JObject o = new JObject();
|
||||
Assert.AreEqual(null, o[0]);
|
||||
});
|
||||
ExceptionAssert.Throws<ArgumentException>(() =>
|
||||
{
|
||||
JObject o = new JObject();
|
||||
Assert.AreEqual(null, o[0]);
|
||||
}, "Accessed JObject values with invalid key value: 0. Object property name expected.");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void JArrayStringIndex()
|
||||
{
|
||||
ExceptionAssert.Throws<ArgumentException>(@"Accessed JArray values with invalid key value: ""purple"". Array position index expected.",
|
||||
() =>
|
||||
{
|
||||
JArray a = new JArray();
|
||||
Assert.AreEqual(null, a["purple"]);
|
||||
});
|
||||
ExceptionAssert.Throws<ArgumentException>(() =>
|
||||
{
|
||||
JArray a = new JArray();
|
||||
Assert.AreEqual(null, a["purple"]);
|
||||
}, @"Accessed JArray values with invalid key value: ""purple"". Array position index expected.");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void JConstructorStringIndex()
|
||||
{
|
||||
ExceptionAssert.Throws<ArgumentException>(@"Accessed JConstructor values with invalid key value: ""purple"". Argument position index expected.",
|
||||
() =>
|
||||
{
|
||||
JConstructor c = new JConstructor("ConstructorValue");
|
||||
Assert.AreEqual(null, c["purple"]);
|
||||
});
|
||||
ExceptionAssert.Throws<ArgumentException>(() =>
|
||||
{
|
||||
JConstructor c = new JConstructor("ConstructorValue");
|
||||
Assert.AreEqual(null, c["purple"]);
|
||||
}, @"Accessed JConstructor values with invalid key value: ""purple"". Argument position index expected.");
|
||||
}
|
||||
|
||||
#if !NET20
|
||||
@@ -1065,13 +1061,12 @@ keyword such as type of business.""
|
||||
IDictionary<string, string> users = new Dictionary<string, string>();
|
||||
|
||||
// unfortunatly there doesn't appear to be a way around this
|
||||
ExceptionAssert.Throws<Microsoft.CSharp.RuntimeBinder.RuntimeBinderException>("The best overloaded method match for 'System.Collections.Generic.IDictionary<string,string>.Add(string, string)' has some invalid arguments",
|
||||
() =>
|
||||
{
|
||||
users.Add("name2", name);
|
||||
ExceptionAssert.Throws<Microsoft.CSharp.RuntimeBinder.RuntimeBinderException>(() =>
|
||||
{
|
||||
users.Add("name2", name);
|
||||
|
||||
Assert.AreEqual(users["name2"], "Matthew Doig");
|
||||
});
|
||||
Assert.AreEqual(users["name2"], "Matthew Doig");
|
||||
}, "The best overloaded method match for 'System.Collections.Generic.IDictionary<string,string>.Add(string, string)' has some invalid arguments");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user