-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
@@ -32,6 +32,7 @@ using System.Text;
using Newtonsoft.Json.Converters;
#if !NETFX_CORE
using NUnit.Framework;
#else
using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute;
@@ -40,17 +41,17 @@ using Test = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestMethodAtt
namespace Newtonsoft.Json.Tests.Serialization
{
[TestFixture]
public class EntitiesSerializationTests : TestFixtureBase
{
[Test]
public void SerializeEntity()
[TestFixture]
public class EntitiesSerializationTests : TestFixtureBase
{
Folder rootFolder = CreateEntitiesTestData();
[Test]
public void SerializeEntity()
{
Folder rootFolder = CreateEntitiesTestData();
string json = JsonConvert.SerializeObject(rootFolder, Formatting.Indented, new IsoDateTimeConverter());
string json = JsonConvert.SerializeObject(rootFolder, Formatting.Indented, new IsoDateTimeConverter());
string expected = @"{
string expected = @"{
""$id"": ""1"",
""FolderId"": ""a4e8ba80-eb24-4591-bb1c-62d3ad83701e"",
""Name"": ""Root folder"",
@@ -121,13 +122,13 @@ namespace Newtonsoft.Json.Tests.Serialization
}
}";
Assert.AreEqual(expected, json);
}
Assert.AreEqual(expected, json);
}
[Test]
public void DeserializeEntity()
{
string json = @"{
[Test]
public void DeserializeEntity()
{
string json = @"{
""$id"": ""1"",
""FolderId"": ""a4e8ba80-eb24-4591-bb1c-62d3ad83701e"",
""Name"": ""Root folder"",
@@ -198,48 +199,48 @@ namespace Newtonsoft.Json.Tests.Serialization
}
}";
Folder f = JsonConvert.DeserializeObject<Folder>(json, new IsoDateTimeConverter());
Folder f = JsonConvert.DeserializeObject<Folder>(json, new IsoDateTimeConverter());
Assert.IsNotNull(f);
Assert.AreEqual(new Guid("A4E8BA80-EB24-4591-BB1C-62D3AD83701E"), f.FolderId);
Assert.AreEqual("Folder", f.EntityKey.EntitySetName);
Assert.AreEqual("DataServicesTestDatabaseEntities", f.EntityKey.EntityContainerName);
Assert.AreEqual("Folder", f.EntityKey.EntitySetName);
Assert.AreEqual(false, f.EntityKey.IsTemporary);
Assert.AreEqual(1, f.EntityKey.EntityKeyValues.Length);
Assert.AreEqual("FolderId", f.EntityKey.EntityKeyValues[0].Key);
Assert.AreEqual(new Guid("A4E8BA80-EB24-4591-BB1C-62D3AD83701E"), f.EntityKey.EntityKeyValues[0].Value);
Assert.AreEqual("Root folder", f.Name);
Assert.AreEqual(new DateTime(2000, 12, 10, 10, 50, 0, DateTimeKind.Utc), f.CreatedDate);
Assert.AreEqual(null, f.ParentFolder);
Assert.AreEqual(1, f.ChildFolders.Count);
Assert.IsNotNull(f);
Assert.AreEqual(new Guid("A4E8BA80-EB24-4591-BB1C-62D3AD83701E"), f.FolderId);
Assert.AreEqual("Folder", f.EntityKey.EntitySetName);
Assert.AreEqual("DataServicesTestDatabaseEntities", f.EntityKey.EntityContainerName);
Assert.AreEqual("Folder", f.EntityKey.EntitySetName);
Assert.AreEqual(false, f.EntityKey.IsTemporary);
Assert.AreEqual(1, f.EntityKey.EntityKeyValues.Length);
Assert.AreEqual("FolderId", f.EntityKey.EntityKeyValues[0].Key);
Assert.AreEqual(new Guid("A4E8BA80-EB24-4591-BB1C-62D3AD83701E"), f.EntityKey.EntityKeyValues[0].Value);
Assert.AreEqual("Root folder", f.Name);
Assert.AreEqual(new DateTime(2000, 12, 10, 10, 50, 0, DateTimeKind.Utc), f.CreatedDate);
Assert.AreEqual(null, f.ParentFolder);
Assert.AreEqual(1, f.ChildFolders.Count);
Folder childFolder = f.ChildFolders.ElementAt(0);
Folder childFolder = f.ChildFolders.ElementAt(0);
Assert.AreEqual("Child folder", childFolder.Name);
Assert.AreEqual("Description!", childFolder.Description);
Assert.AreEqual(f, childFolder.ParentFolder);
Assert.AreEqual(f, childFolder.ParentFolderReference.Value);
// is this a problem?
Assert.AreEqual(null, childFolder.ParentFolderReference.EntityKey);
}
Assert.AreEqual("Child folder", childFolder.Name);
Assert.AreEqual("Description!", childFolder.Description);
Assert.AreEqual(f, childFolder.ParentFolder);
Assert.AreEqual(f, childFolder.ParentFolderReference.Value);
// is this a problem?
Assert.AreEqual(null, childFolder.ParentFolderReference.EntityKey);
}
[Test]
public void SerializeMultiValueEntityKey()
{
EntityKey e = new EntityKey("DataServicesTestDatabaseEntities.Folder",
new List<EntityKeyMember>
{
new EntityKeyMember("GuidId", new Guid("A4E8BA80-EB24-4591-BB1C-62D3AD83701E")),
new EntityKeyMember("IntId", int.MaxValue),
new EntityKeyMember("LongId", long.MaxValue),
new EntityKeyMember("StringId", "String!"),
new EntityKeyMember("DateTimeId", new DateTime(2000, 12, 10, 10, 50, 0, DateTimeKind.Utc))
});
[Test]
public void SerializeMultiValueEntityKey()
{
EntityKey e = new EntityKey("DataServicesTestDatabaseEntities.Folder",
new List<EntityKeyMember>
{
new EntityKeyMember("GuidId", new Guid("A4E8BA80-EB24-4591-BB1C-62D3AD83701E")),
new EntityKeyMember("IntId", int.MaxValue),
new EntityKeyMember("LongId", long.MaxValue),
new EntityKeyMember("StringId", "String!"),
new EntityKeyMember("DateTimeId", new DateTime(2000, 12, 10, 10, 50, 0, DateTimeKind.Utc))
});
string json = JsonConvert.SerializeObject(e, Formatting.Indented);
string json = JsonConvert.SerializeObject(e, Formatting.Indented);
Assert.AreEqual(@"{
Assert.AreEqual(@"{
""$id"": ""1"",
""EntitySetName"": ""Folder"",
""EntityContainerName"": ""DataServicesTestDatabaseEntities"",
@@ -272,50 +273,51 @@ namespace Newtonsoft.Json.Tests.Serialization
]
}", json);
EntityKey newKey = JsonConvert.DeserializeObject<EntityKey>(json);
Assert.IsFalse(ReferenceEquals(e, newKey));
EntityKey newKey = JsonConvert.DeserializeObject<EntityKey>(json);
Assert.IsFalse(ReferenceEquals(e, newKey));
Assert.AreEqual(5, newKey.EntityKeyValues.Length);
Assert.AreEqual("GuidId", newKey.EntityKeyValues[0].Key);
Assert.AreEqual(new Guid("A4E8BA80-EB24-4591-BB1C-62D3AD83701E"), newKey.EntityKeyValues[0].Value);
Assert.AreEqual("IntId", newKey.EntityKeyValues[1].Key);
Assert.AreEqual(int.MaxValue, newKey.EntityKeyValues[1].Value);
Assert.AreEqual("LongId", newKey.EntityKeyValues[2].Key);
Assert.AreEqual(long.MaxValue, newKey.EntityKeyValues[2].Value);
Assert.AreEqual("StringId", newKey.EntityKeyValues[3].Key);
Assert.AreEqual("String!", newKey.EntityKeyValues[3].Value);
Assert.AreEqual("DateTimeId", newKey.EntityKeyValues[4].Key);
Assert.AreEqual(new DateTime(2000, 12, 10, 10, 50, 0, DateTimeKind.Utc), newKey.EntityKeyValues[4].Value);
Assert.AreEqual(5, newKey.EntityKeyValues.Length);
Assert.AreEqual("GuidId", newKey.EntityKeyValues[0].Key);
Assert.AreEqual(new Guid("A4E8BA80-EB24-4591-BB1C-62D3AD83701E"), newKey.EntityKeyValues[0].Value);
Assert.AreEqual("IntId", newKey.EntityKeyValues[1].Key);
Assert.AreEqual(int.MaxValue, newKey.EntityKeyValues[1].Value);
Assert.AreEqual("LongId", newKey.EntityKeyValues[2].Key);
Assert.AreEqual(long.MaxValue, newKey.EntityKeyValues[2].Value);
Assert.AreEqual("StringId", newKey.EntityKeyValues[3].Key);
Assert.AreEqual("String!", newKey.EntityKeyValues[3].Value);
Assert.AreEqual("DateTimeId", newKey.EntityKeyValues[4].Key);
Assert.AreEqual(new DateTime(2000, 12, 10, 10, 50, 0, DateTimeKind.Utc), newKey.EntityKeyValues[4].Value);
}
private Folder CreateEntitiesTestData()
{
Folder folder = new Folder();
folder.FolderId = new Guid("A4E8BA80-EB24-4591-BB1C-62D3AD83701E");
folder.EntityKey = new EntityKey("DataServicesTestDatabaseEntities.Folder", "FolderId", folder.FolderId);
folder.Name = "Root folder";
folder.Description = "Description!";
folder.CreatedDate = new DateTime(2000, 12, 10, 10, 50, 0, DateTimeKind.Utc);
Folder childFolder = new Folder();
childFolder.FolderId = new Guid("484936E2-7CBB-4592-93FF-B2103E5705E4");
childFolder.EntityKey = new EntityKey("DataServicesTestDatabaseEntities.Folder", "FolderId", childFolder.FolderId);
childFolder.Name = "Child folder";
childFolder.Description = "Description!";
childFolder.CreatedDate = new DateTime(2001, 11, 20, 10, 50, 0, DateTimeKind.Utc);
folder.ChildFolders.Add(childFolder);
File file1 = new File();
file1.FileId = new Guid("CC76D734-49F1-4616-BB38-41514228AC6C");
file1.EntityKey = new EntityKey("DataServicesTestDatabaseEntities.File", "FileId", file1.FileId);
file1.Name = "File 1";
file1.Description = "Description!";
file1.CreatedDate = new DateTime(2002, 10, 30, 10, 50, 0, DateTimeKind.Utc);
childFolder.Files.Add(file1);
return folder;
}
}
private Folder CreateEntitiesTestData()
{
Folder folder = new Folder();
folder.FolderId = new Guid("A4E8BA80-EB24-4591-BB1C-62D3AD83701E");
folder.EntityKey = new EntityKey("DataServicesTestDatabaseEntities.Folder", "FolderId", folder.FolderId);
folder.Name = "Root folder";
folder.Description = "Description!";
folder.CreatedDate = new DateTime(2000, 12, 10, 10, 50, 0, DateTimeKind.Utc);
Folder childFolder = new Folder();
childFolder.FolderId = new Guid("484936E2-7CBB-4592-93FF-B2103E5705E4");
childFolder.EntityKey = new EntityKey("DataServicesTestDatabaseEntities.Folder", "FolderId", childFolder.FolderId);
childFolder.Name = "Child folder";
childFolder.Description = "Description!";
childFolder.CreatedDate = new DateTime(2001, 11, 20, 10, 50, 0, DateTimeKind.Utc);
folder.ChildFolders.Add(childFolder);
File file1 = new File();
file1.FileId = new Guid("CC76D734-49F1-4616-BB38-41514228AC6C");
file1.EntityKey = new EntityKey("DataServicesTestDatabaseEntities.File", "FileId", file1.FileId);
file1.Name = "File 1";
file1.Description = "Description!";
file1.CreatedDate = new DateTime(2002, 10, 30, 10, 50, 0, DateTimeKind.Utc);
childFolder.Files.Add(file1);
return folder;
}
}
}
#endif