Cleanup to remove warnings
This commit is contained in:
1 parent
f9e85d8168
commit
206a6cda35
1 file changed
+47
-44
@@ -1,6 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Xml;
|
using System.Xml;
|
||||||
using System.Xml.Serialization;
|
using System.Xml.Serialization;
|
||||||
@@ -15,9 +14,11 @@ namespace VocaluxeTests
|
|||||||
[TestClass]
|
[TestClass]
|
||||||
public class CXmlSerializerTest
|
public class CXmlSerializerTest
|
||||||
{
|
{
|
||||||
private const string sHead = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n";
|
private const string _Head = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n";
|
||||||
private const string sEmpty = sHead + @"<root />";
|
private const string _Empty = _Head + @"<root />";
|
||||||
|
|
||||||
|
#pragma warning disable 649
|
||||||
|
#pragma warning disable 169
|
||||||
private struct SBasic
|
private struct SBasic
|
||||||
{
|
{
|
||||||
public int I;
|
public int I;
|
||||||
@@ -26,6 +27,38 @@ namespace VocaluxeTests
|
|||||||
public double D;
|
public double D;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[XmlType("Entry")]
|
||||||
|
private struct SEntry
|
||||||
|
{
|
||||||
|
public int I;
|
||||||
|
}
|
||||||
|
|
||||||
|
private struct SList
|
||||||
|
{
|
||||||
|
[XmlArray] public List<SEntry> Ints;
|
||||||
|
}
|
||||||
|
|
||||||
|
private struct SArray
|
||||||
|
{
|
||||||
|
[XmlArray] public SEntry[] Ints;
|
||||||
|
}
|
||||||
|
|
||||||
|
private struct SListEmb
|
||||||
|
{
|
||||||
|
public int I;
|
||||||
|
[XmlElement("Entry")] public List<SEntry> Ints;
|
||||||
|
public int J;
|
||||||
|
}
|
||||||
|
|
||||||
|
private struct SArrayEmb
|
||||||
|
{
|
||||||
|
public int I;
|
||||||
|
[XmlElement("Entry")] public SEntry[] Ints;
|
||||||
|
public int J;
|
||||||
|
}
|
||||||
|
#pragma warning restore 169
|
||||||
|
#pragma warning restore 649
|
||||||
|
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void TestBasic()
|
public void TestBasic()
|
||||||
{
|
{
|
||||||
@@ -113,7 +146,7 @@ namespace VocaluxeTests
|
|||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void TestBasicSerialization()
|
public void TestBasicSerialization()
|
||||||
{
|
{
|
||||||
const string s = sHead + @"<root>
|
const string s = _Head + @"<root>
|
||||||
<I>1</I>
|
<I>1</I>
|
||||||
<S>2</S>
|
<S>2</S>
|
||||||
<F>3</F>
|
<F>3</F>
|
||||||
@@ -127,7 +160,7 @@ namespace VocaluxeTests
|
|||||||
|
|
||||||
private readonly string[] _XMLList = new string[]
|
private readonly string[] _XMLList = new string[]
|
||||||
{
|
{
|
||||||
sHead + @"<root>
|
_Head + @"<root>
|
||||||
<Ints>
|
<Ints>
|
||||||
<Entry>
|
<Entry>
|
||||||
<I>1</I>
|
<I>1</I>
|
||||||
@@ -137,26 +170,15 @@ namespace VocaluxeTests
|
|||||||
</Entry>
|
</Entry>
|
||||||
</Ints>
|
</Ints>
|
||||||
</root>",
|
</root>",
|
||||||
sHead + @"<root>
|
_Head + @"<root>
|
||||||
<Ints>
|
<Ints>
|
||||||
</Ints>
|
</Ints>
|
||||||
</root>",
|
</root>",
|
||||||
sHead + @"<root>
|
_Head + @"<root>
|
||||||
<Ints />
|
<Ints />
|
||||||
</root>"
|
</root>"
|
||||||
};
|
};
|
||||||
|
|
||||||
[XmlType("Entry")]
|
|
||||||
private struct SEntry
|
|
||||||
{
|
|
||||||
public int I;
|
|
||||||
}
|
|
||||||
|
|
||||||
private struct SList
|
|
||||||
{
|
|
||||||
[XmlArray] public List<SEntry> Ints;
|
|
||||||
}
|
|
||||||
|
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void TestList()
|
public void TestList()
|
||||||
{
|
{
|
||||||
@@ -175,12 +197,7 @@ namespace VocaluxeTests
|
|||||||
Assert.AreEqual(foo.Ints.Count, 0, "Deserialization2 failed");
|
Assert.AreEqual(foo.Ints.Count, 0, "Deserialization2 failed");
|
||||||
res = xml.Serialize(foo);
|
res = xml.Serialize(foo);
|
||||||
Assert.AreEqual(_XMLList[2], res, "Serialization2 failed");
|
Assert.AreEqual(_XMLList[2], res, "Serialization2 failed");
|
||||||
_AssertFail<XmlException>(() => xml.DeserializeString<SList>(sEmpty));
|
_AssertFail<XmlException>(() => xml.DeserializeString<SList>(_Empty));
|
||||||
}
|
|
||||||
|
|
||||||
private struct SArray
|
|
||||||
{
|
|
||||||
[XmlArray] public SEntry[] Ints;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
@@ -201,17 +218,17 @@ namespace VocaluxeTests
|
|||||||
Assert.AreEqual(foo.Ints.Length, 0, "Deserialization2 failed");
|
Assert.AreEqual(foo.Ints.Length, 0, "Deserialization2 failed");
|
||||||
res = xml.Serialize(foo);
|
res = xml.Serialize(foo);
|
||||||
Assert.AreEqual(_XMLList[2], res, "Serialization2 failed");
|
Assert.AreEqual(_XMLList[2], res, "Serialization2 failed");
|
||||||
_AssertFail<XmlException>(() => xml.DeserializeString<SArray>(sEmpty));
|
_AssertFail<XmlException>(() => xml.DeserializeString<SArray>(_Empty));
|
||||||
}
|
}
|
||||||
|
|
||||||
private const string _XMLListEmb = sHead + @"<root>
|
private const string _XMLListEmb = _Head + @"<root>
|
||||||
<I>2</I>
|
<I>2</I>
|
||||||
<Entry>
|
<Entry>
|
||||||
<I>1</I>
|
<I>1</I>
|
||||||
</Entry>
|
</Entry>
|
||||||
<J>3</J>
|
<J>3</J>
|
||||||
</root>";
|
</root>";
|
||||||
private const string _XMLListEmb2 = sHead + @"<root>
|
private const string _XMLListEmb2 = _Head + @"<root>
|
||||||
<I>2</I>
|
<I>2</I>
|
||||||
<Entry>
|
<Entry>
|
||||||
<I>1</I>
|
<I>1</I>
|
||||||
@@ -221,18 +238,11 @@ namespace VocaluxeTests
|
|||||||
</Entry>
|
</Entry>
|
||||||
<J>3</J>
|
<J>3</J>
|
||||||
</root>";
|
</root>";
|
||||||
private const string _XMLListEmb3 = sHead + @"<root>
|
private const string _XMLListEmb3 = _Head + @"<root>
|
||||||
<I>2</I>
|
<I>2</I>
|
||||||
<J>3</J>
|
<J>3</J>
|
||||||
</root>";
|
</root>";
|
||||||
|
|
||||||
private struct SListEmb
|
|
||||||
{
|
|
||||||
public int I;
|
|
||||||
[XmlElement("Entry")] public List<SEntry> Ints;
|
|
||||||
public int J;
|
|
||||||
}
|
|
||||||
|
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void TestListEmbedded()
|
public void TestListEmbedded()
|
||||||
{
|
{
|
||||||
@@ -251,14 +261,7 @@ namespace VocaluxeTests
|
|||||||
Assert.AreEqual(foo.Ints.Count, 0, "Deserialization failed");
|
Assert.AreEqual(foo.Ints.Count, 0, "Deserialization failed");
|
||||||
res = xml.Serialize(foo);
|
res = xml.Serialize(foo);
|
||||||
Assert.AreEqual(_XMLListEmb3, res, "Serialization failed");
|
Assert.AreEqual(_XMLListEmb3, res, "Serialization failed");
|
||||||
_AssertFail<XmlException>(() => xml.DeserializeString<SListEmb>(sEmpty));
|
_AssertFail<XmlException>(() => xml.DeserializeString<SListEmb>(_Empty));
|
||||||
}
|
|
||||||
|
|
||||||
private struct SArrayEmb
|
|
||||||
{
|
|
||||||
public int I;
|
|
||||||
[XmlElement("Entry")] public SEntry[] Ints;
|
|
||||||
public int J;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
@@ -279,7 +282,7 @@ namespace VocaluxeTests
|
|||||||
Assert.AreEqual(foo.Ints.Length, 0, "Deserialization failed");
|
Assert.AreEqual(foo.Ints.Length, 0, "Deserialization failed");
|
||||||
res = xml.Serialize(foo);
|
res = xml.Serialize(foo);
|
||||||
Assert.AreEqual(_XMLListEmb3, res, "Serialization failed");
|
Assert.AreEqual(_XMLListEmb3, res, "Serialization failed");
|
||||||
_AssertFail<XmlException>(() => xml.DeserializeString<SArrayEmb>(sEmpty));
|
_AssertFail<XmlException>(() => xml.DeserializeString<SArrayEmb>(_Empty));
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
|
|||||||
Reference in new issue
Block a user