-Fixed deserializing Regex when using StringEnumConverter

-Fixed serializing and deserializing typed DataSets
This commit is contained in:
James Newton-King
2013-05-04 15:28:01 +12:00
parent b6816866ba
commit 6f2b931a90
22 changed files with 393 additions and 39 deletions
@@ -403,6 +403,56 @@ namespace Newtonsoft.Json.Tests.Converters
Assert.AreEqual(c.Table.Rows.Count, c2.Table.Rows.Count);
Assert.AreEqual(c.After, c2.After);
}
[Test]
public void SerializedTypedDataSet()
{
CustomerDataSet ds = new CustomerDataSet();
ds.Customers.AddCustomersRow("234");
string json = JsonConvert.SerializeObject(ds, Formatting.Indented);
Assert.AreEqual(@"{
""Customers"": [
{
""CustomerID"": ""234""
}
]
}", json);
CustomerDataSet ds1 = new CustomerDataSet();
DataTable table = ds1.Tables["Customers"];
DataRow row = ds1.Tables["Customers"].NewRow();
row["CustomerID"] = "234";
table.Rows.Add(row);
string json1 = JsonConvert.SerializeObject(ds1, Formatting.Indented);
Assert.AreEqual(@"{
""Customers"": [
{
""CustomerID"": ""234""
}
]
}", json1);
}
[Test]
public void DeserializedTypedDataSet()
{
string json = @"{
""Customers"": [
{
""CustomerID"": ""234""
}
]
}";
var ds = JsonConvert.DeserializeObject<CustomerDataSet>(json);
Assert.AreEqual("234", ds.Customers[0].CustomerID);
}
}
}
#endif