More options to serialize dictionaries

This commit is contained in:
Flamefire committed 2014-10-30 16:32:39 +01:00
1 parent 61a0d4fdf1
commit 0c5dcd9c74
3 files changed
+129 -27

No files matched your search

+31 -3
View File
@@ -393,6 +393,26 @@ namespace VocaluxeTests
Assert.AreEqual(_XmlIgnore, xml.Serialize(bar2));
}
[TestMethod]
public void TestOnlyList()
{
const string s = _Head + @"<root>
<String>2</String>
<String>3</String>
</root>";
_AssertSerDeserMatch<List<string>>(s);
}
[TestMethod]
public void TestOnlyDict()
{
const string s = _Head + @"<root>
<String name=""val1"">2</String>
<String name=""val2"">3</String>
</root>";
_AssertSerDeserMatch<Dictionary<string, string>>(s);
}
[TestMethod]
public void TestRealFiles()
{
@@ -402,11 +422,19 @@ namespace VocaluxeTests
{
string xmlPath = Path.Combine(filePath, type.Name + ".xml");
var xml = new CXmlSerializer(type == typeof(CConfig.SConfig));
object foo = xml.Deserialize(xmlPath, Activator.CreateInstance(type));
Assert.IsInstanceOfType(foo, type);
object foo = null;
try
{
foo = xml.Deserialize(xmlPath, Activator.CreateInstance(type));
}
catch (Exception e)
{
Assert.Fail("Exception with " + type.Name + ": {0}", new object[] {e.Message});
}
Assert.IsInstanceOfType(foo, type, "Wrong type with " + type.Name);
string newXml = xml.Serialize(foo);
string oldXml = File.ReadAllText(xmlPath);
Assert.AreEqual(oldXml, newXml, "Error in " + type.Name);
Assert.AreEqual(oldXml, newXml, "Error with " + type.Name);
}
}
}