-Refactor ExceptionAssert
This commit is contained in:
@@ -161,12 +161,10 @@ namespace Newtonsoft.Json.Tests.Serialization
|
||||
Assert.IsNull(contract.DefaultCreator);
|
||||
Assert.IsNull(contract.OverrideCreator);
|
||||
|
||||
ExceptionAssert.Throws<JsonSerializationException>(
|
||||
"Could not create an instance of type Newtonsoft.Json.Tests.Serialization.AbstractTestClass. Type is an interface or abstract class and cannot be instantiated. Path 'Value', line 1, position 7.",
|
||||
() => JsonConvert.DeserializeObject<AbstractTestClass>(@"{Value:'Value!'}", new JsonSerializerSettings
|
||||
{
|
||||
ContractResolver = resolver
|
||||
}));
|
||||
ExceptionAssert.Throws<JsonSerializationException>(() => JsonConvert.DeserializeObject<AbstractTestClass>(@"{Value:'Value!'}", new JsonSerializerSettings
|
||||
{
|
||||
ContractResolver = resolver
|
||||
}), "Could not create an instance of type Newtonsoft.Json.Tests.Serialization.AbstractTestClass. Type is an interface or abstract class and cannot be instantiated. Path 'Value', line 1, position 7.");
|
||||
|
||||
contract.DefaultCreator = () => new AbstractImplementationTestClass();
|
||||
|
||||
@@ -188,12 +186,10 @@ namespace Newtonsoft.Json.Tests.Serialization
|
||||
Assert.IsNull(contract.DefaultCreator);
|
||||
Assert.IsFalse(contract.HasParametrizedCreator);
|
||||
|
||||
ExceptionAssert.Throws<JsonSerializationException>(
|
||||
"Could not create an instance of type Newtonsoft.Json.Tests.Serialization.AbstractListTestClass`1[System.Int32]. Type is an interface or abstract class and cannot be instantiated. Path '', line 1, position 1.",
|
||||
() => JsonConvert.DeserializeObject<AbstractListTestClass<int>>(@"[1,2]", new JsonSerializerSettings
|
||||
{
|
||||
ContractResolver = resolver
|
||||
}));
|
||||
ExceptionAssert.Throws<JsonSerializationException>(() => JsonConvert.DeserializeObject<AbstractListTestClass<int>>(@"[1,2]", new JsonSerializerSettings
|
||||
{
|
||||
ContractResolver = resolver
|
||||
}), "Could not create an instance of type Newtonsoft.Json.Tests.Serialization.AbstractListTestClass`1[System.Int32]. Type is an interface or abstract class and cannot be instantiated. Path '', line 1, position 1.");
|
||||
|
||||
contract.DefaultCreator = () => new AbstractImplementationListTestClass<int>();
|
||||
|
||||
@@ -270,12 +266,10 @@ namespace Newtonsoft.Json.Tests.Serialization
|
||||
Assert.IsNull(contract.DefaultCreator);
|
||||
Assert.IsFalse(contract.HasParametrizedCreator);
|
||||
|
||||
ExceptionAssert.Throws<JsonSerializationException>(
|
||||
"Could not create an instance of type Newtonsoft.Json.Tests.Serialization.AbstractDictionaryTestClass`2[System.String,System.Int32]. Type is an interface or abstract class and cannot be instantiated. Path 'key1', line 1, position 6.",
|
||||
() => JsonConvert.DeserializeObject<AbstractDictionaryTestClass<string, int>>(@"{key1:1,key2:2}", new JsonSerializerSettings
|
||||
{
|
||||
ContractResolver = resolver
|
||||
}));
|
||||
ExceptionAssert.Throws<JsonSerializationException>(() => JsonConvert.DeserializeObject<AbstractDictionaryTestClass<string, int>>(@"{key1:1,key2:2}", new JsonSerializerSettings
|
||||
{
|
||||
ContractResolver = resolver
|
||||
}), "Could not create an instance of type Newtonsoft.Json.Tests.Serialization.AbstractDictionaryTestClass`2[System.String,System.Int32]. Type is an interface or abstract class and cannot be instantiated. Path 'key1', line 1, position 6.");
|
||||
|
||||
contract.DefaultCreator = () => new AbstractImplementationDictionaryTestClass<string, int>();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user