-Code reformat

This commit is contained in:
James Newton-King
2013-10-20 15:08:39 +13:00
parent d03963016e
commit bcd6982419
466 changed files with 71645 additions and 71598 deletions
@@ -48,40 +48,40 @@ using Newtonsoft.Json.Tests.TestObjects;
namespace Newtonsoft.Json.Tests.Converters
{
[TestFixture]
public class ExpandoObjectConverterTests : TestFixtureBase
{
public class ExpandoContainer
[TestFixture]
public class ExpandoObjectConverterTests : TestFixtureBase
{
public string Before { get; set; }
public ExpandoObject Expando { get; set; }
public string After { get; set; }
}
[Test]
public void SerializeExpandoObject()
{
ExpandoContainer d = new ExpandoContainer
public class ExpandoContainer
{
Before = "Before!",
Expando = new ExpandoObject(),
After = "After!"
};
public string Before { get; set; }
public ExpandoObject Expando { get; set; }
public string After { get; set; }
}
dynamic o = d.Expando;
o.String = "String!";
o.Integer = 234;
o.Float = 1.23d;
o.List = new List<string> {"First", "Second", "Third"};
o.Object = new Dictionary<string, object>
[Test]
public void SerializeExpandoObject()
{
{"First", 1}
};
ExpandoContainer d = new ExpandoContainer
{
Before = "Before!",
Expando = new ExpandoObject(),
After = "After!"
};
string json = JsonConvert.SerializeObject(d, Formatting.Indented);
dynamic o = d.Expando;
Assert.AreEqual(@"{
o.String = "String!";
o.Integer = 234;
o.Float = 1.23d;
o.List = new List<string> { "First", "Second", "Third" };
o.Object = new Dictionary<string, object>
{
{ "First", 1 }
};
string json = JsonConvert.SerializeObject(d, Formatting.Indented);
Assert.AreEqual(@"{
""Before"": ""Before!"",
""Expando"": {
""String"": ""String!"",
@@ -98,26 +98,26 @@ namespace Newtonsoft.Json.Tests.Converters
},
""After"": ""After!""
}", json);
}
}
[Test]
public void SerializeNullExpandoObject()
{
ExpandoContainer d = new ExpandoContainer();
[Test]
public void SerializeNullExpandoObject()
{
ExpandoContainer d = new ExpandoContainer();
string json = JsonConvert.SerializeObject(d, Formatting.Indented);
string json = JsonConvert.SerializeObject(d, Formatting.Indented);
Assert.AreEqual(@"{
Assert.AreEqual(@"{
""Before"": null,
""Expando"": null,
""After"": null
}", json);
}
}
[Test]
public void DeserializeExpandoObject()
{
string json = @"{
[Test]
public void DeserializeExpandoObject()
{
string json = @"{
""Before"": ""Before!"",
""Expando"": {
""String"": ""String!"",
@@ -135,56 +135,55 @@ namespace Newtonsoft.Json.Tests.Converters
""After"": ""After!""
}";
ExpandoContainer o = JsonConvert.DeserializeObject<ExpandoContainer>(json);
ExpandoContainer o = JsonConvert.DeserializeObject<ExpandoContainer>(json);
Assert.AreEqual(o.Before, "Before!");
Assert.AreEqual(o.After, "After!");
Assert.IsNotNull(o.Expando);
Assert.AreEqual(o.Before, "Before!");
Assert.AreEqual(o.After, "After!");
Assert.IsNotNull(o.Expando);
dynamic d = o.Expando;
CustomAssert.IsInstanceOfType(typeof(ExpandoObject), d);
dynamic d = o.Expando;
CustomAssert.IsInstanceOfType(typeof(ExpandoObject), d);
Assert.AreEqual("String!", d.String);
CustomAssert.IsInstanceOfType(typeof(string), d.String);
Assert.AreEqual("String!", d.String);
CustomAssert.IsInstanceOfType(typeof(string), d.String);
Assert.AreEqual(234, d.Integer);
CustomAssert.IsInstanceOfType(typeof(long), d.Integer);
Assert.AreEqual(234, d.Integer);
CustomAssert.IsInstanceOfType(typeof(long), d.Integer);
Assert.AreEqual(1.23, d.Float);
CustomAssert.IsInstanceOfType(typeof(double), d.Float);
Assert.AreEqual(1.23, d.Float);
CustomAssert.IsInstanceOfType(typeof(double), d.Float);
Assert.IsNotNull(d.List);
Assert.AreEqual(3, d.List.Count);
CustomAssert.IsInstanceOfType(typeof(List<object>), d.List);
Assert.IsNotNull(d.List);
Assert.AreEqual(3, d.List.Count);
CustomAssert.IsInstanceOfType(typeof(List<object>), d.List);
Assert.AreEqual("First", d.List[0]);
CustomAssert.IsInstanceOfType(typeof(string), d.List[0]);
Assert.AreEqual("First", d.List[0]);
CustomAssert.IsInstanceOfType(typeof(string), d.List[0]);
Assert.AreEqual("Second", d.List[1]);
Assert.AreEqual("Third", d.List[2]);
Assert.AreEqual("Second", d.List[1]);
Assert.AreEqual("Third", d.List[2]);
Assert.IsNotNull(d.Object);
CustomAssert.IsInstanceOfType(typeof(ExpandoObject), d.Object);
Assert.IsNotNull(d.Object);
CustomAssert.IsInstanceOfType(typeof(ExpandoObject), d.Object);
Assert.AreEqual(1, d.Object.First);
CustomAssert.IsInstanceOfType(typeof(long), d.Object.First);
}
Assert.AreEqual(1, d.Object.First);
CustomAssert.IsInstanceOfType(typeof(long), d.Object.First);
}
[Test]
public void DeserializeNullExpandoObject()
{
string json = @"{
[Test]
public void DeserializeNullExpandoObject()
{
string json = @"{
""Before"": null,
""Expando"": null,
""After"": null
}";
ExpandoContainer c = JsonConvert.DeserializeObject<ExpandoContainer>(json);
ExpandoContainer c = JsonConvert.DeserializeObject<ExpandoContainer>(json);
Assert.AreEqual(null, c.Expando);
Assert.AreEqual(null, c.Expando);
}
}
}
}
#endif