public void ET_Json_Serialization_NoCamel() { var entity = new Favorate { Name = "name" }; var serializer = new AggtSerializer(); serializer.Indent = true; serializer.IgnoreDefault = true; serializer.UseCamelProperty = false; var json = serializer.Serialize(entity); Assert.AreEqual(json, @"{ ""Name"": ""name"" }"); }
public void ET_Json_Serialization_Ref() { var entity = new Favorate { Name = "name", Book = new Book { Id = 100, Name = "book" } }; var serializer = new AggtSerializer(); serializer.Indent = true; serializer.IgnoreDefault = true; var json = serializer.Serialize(entity); Assert.AreEqual(json, @"{ ""book"": { ""id"": 100, ""name"": ""book"" }, ""bookId"": 100, ""name"": ""name"" }"); }
public void ET_Json_Serialization_IgnoreDefault() { var entity = new Favorate { Name = "name" }; var serializer = new AggtSerializer(); serializer.Indent = true; serializer.IgnoreDefault = false; var json = serializer.Serialize(entity); Assert.AreEqual(json, @"{ ""id"": 0, ""arrayValue"": null, ""bookId"": 0, ""bytesContent"": """", ""listValue"": null, ""name"": ""name"" }"); }
public void ET_Json_Serialization_EntityList() { var list = new FavorateList { new Favorate { Name = "f1" }, new Favorate { Name = "f2" }, }; var serializer = new AggtSerializer(); serializer.Indent = true; serializer.IgnoreDefault = true; var json = serializer.Serialize(list); Assert.AreEqual(json, @"[ { ""name"": ""f1"" }, { ""name"": ""f2"" } ]"); }
public void ET_Json_Serialization_Bytes() { var entity = new Favorate { BytesContent = Encoding.UTF8.GetBytes("test content") }; var serializer = new AggtSerializer(); serializer.Indent = true; serializer.IgnoreDefault = true; var json = serializer.Serialize(entity); Assert.AreEqual(json, @"{ ""bytesContent"": ""dGVzdCBjb250ZW50"" }"); }
public void ET_Json_Serialization_ArrayValue() { var entity = new Favorate { ListValue = new List<string> { "1", "2", "3" }, ArrayValue = new int[] { 1, 2, 3 }, }; var serializer = new AggtSerializer(); serializer.Indent = true; serializer.IgnoreDefault = true; var json = serializer.Serialize(entity); Assert.AreEqual(json, @"{ ""arrayValue"": [ 1, 2, 3 ], ""listValue"": [ ""1"", ""2"", ""3"" ] }"); }
public void ET_Json_Serialization_Aggt() { var entity = new Book { Name = "book", ChapterList = { new Chapter { Name = "chapter1" }, new Chapter { Name = "chapter2", SectionList = { new Section { Name = "section" } } }, } }; var serializer = new AggtSerializer(); serializer.Indent = true; serializer.IgnoreDefault = true; var json = serializer.Serialize(entity); Assert.AreEqual(json, @"{ ""chapterList"": [ { ""name"": ""chapter1"" }, { ""name"": ""chapter2"", ""sectionList"": [ { ""name"": ""section"" } ] } ], ""name"": ""book"" }"); }