diff --git a/ICD.Common.Utils.Tests/Xml/IcdXmlReaderTest.cs b/ICD.Common.Utils.Tests/Xml/IcdXmlReaderTest.cs new file mode 100644 index 0000000..25ae1c9 --- /dev/null +++ b/ICD.Common.Utils.Tests/Xml/IcdXmlReaderTest.cs @@ -0,0 +1,120 @@ +using ICD.Common.Utils.Xml; +using NUnit.Framework; + +namespace ICD.Common.Utils.Tests.Xml +{ + [TestFixture] + public sealed class IcdXmlReaderTest + { + // Whitespace is important for testing Insignificant Whitespace nodes. + private const string EXAMPLE_XML = " " + + " " + + " " + + " " + + " Some text " + + " " + + " "; + + // For testing empty elements + private const string EXAMPLE_XML_2 = "" + + "" + + "" + + ""; + + #region Properties + + public void HasAttributesTest() + { + IcdXmlReader reader = new IcdXmlReader(EXAMPLE_XML); + reader.SkipToNextElement(); + Assert.IsTrue(reader.HasAttributes); + + reader = new IcdXmlReader(EXAMPLE_XML_2); + reader.SkipToNextElement(); + Assert.IsFalse(reader.HasAttributes); + } + + public void NameTest() + { + IcdXmlReader reader = new IcdXmlReader(EXAMPLE_XML); + reader.SkipToNextElement(); + + Assert.AreEqual("Level1", reader.Name); + + reader.SkipToNextElement(); + + Assert.AreEqual("Level2", reader.Name); + } + + public void ValueTest() + { + Assert.Inconclusive(); + } + + public void NodeTypeTest() + { + Assert.Inconclusive(); + } + + #endregion + + #region Methods + + public void MoveToNextAttributeTest() + { + Assert.Inconclusive(); + } + + public void MoveToElementTest() + { + Assert.Inconclusive(); + } + + public void GetAttributeTest() + { + Assert.Inconclusive(); + } + + public void ReadStringTest() + { + Assert.Inconclusive(); + } + + public void ReadTest() + { + Assert.Inconclusive(); + } + + public void SkipTest() + { + Assert.Inconclusive(); + } + + public void ReadElementContentAsStringTest() + { + Assert.Inconclusive(); + } + + public void ReadOuterXmlTest() + { + Assert.Inconclusive(); + } + + public void ReadInnerXmlTest() + { + Assert.Inconclusive(); + } + + public void ReadElementContentAsLongTest() + { + Assert.Inconclusive(); + } + + public void ReadElementContentAsFloatTest() + { + Assert.Inconclusive(); + } + + #endregion + } +} diff --git a/ICD.Common.Utils.Tests/Xml/XmlUtilsTest.cs b/ICD.Common.Utils.Tests/Xml/XmlUtilsTest.cs index a60b6bb..5ec66a7 100644 --- a/ICD.Common.Utils.Tests/Xml/XmlUtilsTest.cs +++ b/ICD.Common.Utils.Tests/Xml/XmlUtilsTest.cs @@ -29,6 +29,17 @@ namespace ICD.Common.Utils.Tests.Xml + "" + ""; + #region Attributes + + [Test] + public void HasAttributeTest() + { + Assert.IsTrue(XmlUtils.HasAttribute(EXAMPLE_XML, "attr1")); + Assert.IsTrue(XmlUtils.HasAttribute(EXAMPLE_XML, "attr2")); + Assert.IsFalse(XmlUtils.HasAttribute(EXAMPLE_XML, "attr3")); + Assert.IsFalse(XmlUtils.HasAttribute(EXAMPLE_XML_2, "attr1")); + } + [Test, UsedImplicitly] public void GetAttributesTest() { @@ -58,6 +69,8 @@ namespace ICD.Common.Utils.Tests.Xml } } + #endregion + [Test, UsedImplicitly] public void RecursionTest() {