-Refactor tests
This commit is contained in:
@@ -75,10 +75,10 @@ namespace Newtonsoft.Json.Tests.Serialization
|
||||
[Test]
|
||||
public void VirtualShouldSerialize()
|
||||
{
|
||||
var setFoo = new Foo1()
|
||||
var setFoo = new Foo2()
|
||||
{
|
||||
name = Guid.NewGuid().ToString(),
|
||||
myBar = new Bar1()
|
||||
myBar = new Bar2()
|
||||
{
|
||||
name = Guid.NewGuid().ToString(),
|
||||
myBaz = new Baz1[]
|
||||
@@ -112,7 +112,7 @@ namespace Newtonsoft.Json.Tests.Serialization
|
||||
};
|
||||
|
||||
var setFooJson = Serialize(setFoo);
|
||||
var deserializedSetFoo = JsonConvert.DeserializeObject<Foo1>(setFooJson);
|
||||
var deserializedSetFoo = JsonConvert.DeserializeObject<Foo2>(setFooJson);
|
||||
|
||||
Assert.AreEqual(setFoo.name, deserializedSetFoo.name);
|
||||
Assert.IsNotNull(deserializedSetFoo.myBar);
|
||||
@@ -132,7 +132,7 @@ namespace Newtonsoft.Json.Tests.Serialization
|
||||
Assert.AreEqual(true, setFoo.myBar.ShouldSerializemyBazCalled);
|
||||
}
|
||||
|
||||
private string Serialize(Foo1 f)
|
||||
private string Serialize(Foo2 f)
|
||||
{
|
||||
//Code copied from JsonConvert.SerializeObject(), with addition of trace writing
|
||||
JsonSerializer jsonSerializer = JsonSerializer.CreateDefault();
|
||||
@@ -144,7 +144,7 @@ namespace Newtonsoft.Json.Tests.Serialization
|
||||
using (JsonTextWriter jsonWriter = new JsonTextWriter(sw))
|
||||
{
|
||||
jsonWriter.Formatting = Formatting.None;
|
||||
jsonSerializer.Serialize(jsonWriter, f, typeof(Foo1));
|
||||
jsonSerializer.Serialize(jsonWriter, f, typeof(Foo2));
|
||||
}
|
||||
|
||||
return sw.ToString();
|
||||
@@ -513,11 +513,11 @@ namespace Newtonsoft.Json.Tests.Serialization
|
||||
}
|
||||
}
|
||||
|
||||
public class Foo1
|
||||
public class Foo2
|
||||
{
|
||||
private Bar1 myBarField;
|
||||
private Bar2 myBarField;
|
||||
|
||||
public Bar1 myBar
|
||||
public Bar2 myBar
|
||||
{
|
||||
get { return myBarField; }
|
||||
set { myBarField = value; }
|
||||
@@ -542,7 +542,7 @@ namespace Newtonsoft.Json.Tests.Serialization
|
||||
}
|
||||
}
|
||||
|
||||
public class Bar1
|
||||
public class Bar2
|
||||
{
|
||||
[JsonIgnore]
|
||||
public bool ShouldSerializemyBazCalled { get; set; }
|
||||
|
||||
Reference in New Issue
Block a user