diff --git a/ICD.Common.Utils.Tests/Extensions/AssemblyExtensionsTest.cs b/ICD.Common.Utils.Tests/Extensions/AssemblyExtensionsTest.cs new file mode 100644 index 0000000..02122f9 --- /dev/null +++ b/ICD.Common.Utils.Tests/Extensions/AssemblyExtensionsTest.cs @@ -0,0 +1,14 @@ +using NUnit.Framework; + +namespace ICD.Common.Utils.Tests.Extensions +{ + [TestFixture] + public sealed class AssemblyExtensionsTest + { + [Test] + public void GetPathTest() + { + Assert.Inconclusive(); + } + } +} diff --git a/ICD.Common.Utils.Tests/Extensions/CollectionExtensionsTest.cs b/ICD.Common.Utils.Tests/Extensions/CollectionExtensionsTest.cs new file mode 100644 index 0000000..44dd387 --- /dev/null +++ b/ICD.Common.Utils.Tests/Extensions/CollectionExtensionsTest.cs @@ -0,0 +1,34 @@ +using System.Collections.Generic; +using ICD.Common.Utils.Extensions; +using NUnit.Framework; + +namespace ICD.Common.Utils.Tests.Extensions +{ + [TestFixture] + public sealed class CollectionExtensionsTest + { + [Test] + public void RemoveAllPredicateTest() + { + List a = new List {1, 2, 2, 3}; + List b = new List {2, 3}; + + ((ICollection)a).RemoveAll(i => b.Contains(i)); + + Assert.AreEqual(1, a.Count); + Assert.AreEqual(1, a[0]); + } + + [Test] + public void RemoveAllOtherTest() + { + List a = new List {1, 2, 2, 3}; + List b = new List {2, 3}; + + a.RemoveAll(b); + + Assert.AreEqual(1, a.Count); + Assert.AreEqual(1, a[0]); + } + } +} diff --git a/ICD.Common.Utils.Tests/Extensions/DateTimeExtensionsTest.cs b/ICD.Common.Utils.Tests/Extensions/DateTimeExtensionsTest.cs new file mode 100644 index 0000000..12e610d --- /dev/null +++ b/ICD.Common.Utils.Tests/Extensions/DateTimeExtensionsTest.cs @@ -0,0 +1,20 @@ +using NUnit.Framework; + +namespace ICD.Common.Utils.Tests.Extensions +{ + [TestFixture] + public sealed class DateTimeExtensionsTest + { + [Test] + public static void ToShortTimeStringTest() + { + Assert.Inconclusive(); + } + + [Test] + public static void ToLongTimeStringWithMillisecondsTest() + { + Assert.Inconclusive(); + } + } +} diff --git a/ICD.Common.Utils.Tests/Extensions/EnumExtensionsTest.cs b/ICD.Common.Utils.Tests/Extensions/EnumExtensionsTest.cs new file mode 100644 index 0000000..cb2d371 --- /dev/null +++ b/ICD.Common.Utils.Tests/Extensions/EnumExtensionsTest.cs @@ -0,0 +1,26 @@ +using NUnit.Framework; + +namespace ICD.Common.Utils.Tests.Extensions +{ + [TestFixture] + public sealed class EnumExtensionsTest + { + [Test] + public void HasFlagTest() + { + Assert.Inconclusive(); + } + + [Test] + public void HasFlagsTest() + { + Assert.Inconclusive(); + } + + [Test] + public void CastTest() + { + Assert.Inconclusive(); + } + } +} diff --git a/ICD.Common.Utils.Tests/Extensions/EventHandlerExtensionsTest.cs b/ICD.Common.Utils.Tests/Extensions/EventHandlerExtensionsTest.cs new file mode 100644 index 0000000..f3a1973 --- /dev/null +++ b/ICD.Common.Utils.Tests/Extensions/EventHandlerExtensionsTest.cs @@ -0,0 +1,21 @@ +using System; +using NUnit.Framework; + +namespace ICD.Common.Utils.Tests.Extensions +{ + [TestFixture] + public sealed class EventHandlerExtensionsTest + { + [Test] + public void RaiseTest() + { + Assert.Inconclusive(); + } + + [Test] + public void RaiseGenericTest() + { + Assert.Inconclusive(); + } + } +} diff --git a/ICD.Common.Utils.Tests/Extensions/XmlReaderExtensionsTest.cs b/ICD.Common.Utils.Tests/Extensions/XmlReaderExtensionsTest.cs new file mode 100644 index 0000000..ee0176d --- /dev/null +++ b/ICD.Common.Utils.Tests/Extensions/XmlReaderExtensionsTest.cs @@ -0,0 +1,178 @@ +using System; +using System.Linq; +using ICD.Common.Utils.Xml; +using NUnit.Framework; + +namespace ICD.Common.Utils.Tests.Extensions +{ + [TestFixture] + public sealed class XmlReaderExtensionsTest + { + // 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 Attributes + + [Test] + public static void HasAttributeTest() + { + IcdXmlReader reader = new IcdXmlReader(EXAMPLE_XML); + + Assert.IsFalse(reader.HasAttribute("attr1")); + + reader.SkipToNextElement(); + + Assert.IsTrue(reader.HasAttribute("attr1")); + Assert.IsTrue(reader.HasAttribute("attr2")); + Assert.IsFalse(reader.HasAttribute("attr3")); + Assert.IsFalse(reader.HasAttribute("Attr1")); + } + + [Test] + public static void GetAttributesTest() + { + IcdXmlReader reader = new IcdXmlReader(EXAMPLE_XML); + + Assert.IsEmpty(reader.GetAttributes()); + + reader.SkipToNextElement(); + + IcdXmlAttribute[] attributes = reader.GetAttributes().ToArray(); + Assert.AreEqual(2, attributes.Length); + Assert.AreEqual("attr1", attributes[0].Name); + Assert.AreEqual("attr2", attributes[1].Name); + } + + [Test] + public static void GetAttributeAsStringTest() + { + IcdXmlReader reader = new IcdXmlReader(EXAMPLE_XML); + + Assert.Throws(() => reader.GetAttributeAsString("attr1")); + + reader.SkipToNextElement(); + + Assert.AreEqual("1", reader.GetAttributeAsString("attr1")); + Assert.AreEqual("2", reader.GetAttributeAsString("attr2")); + Assert.Throws(() => reader.GetAttributeAsString("attr3")); + Assert.Throws(() => reader.GetAttributeAsString("Attr1")); + } + + [Test] + public static void GetAttributeAsIntTest() + { + IcdXmlReader reader = new IcdXmlReader(EXAMPLE_XML); + + Assert.Throws(() => reader.GetAttributeAsInt("attr1")); + + reader.SkipToNextElement(); + + Assert.AreEqual(1, reader.GetAttributeAsInt("attr1")); + Assert.AreEqual(2, reader.GetAttributeAsInt("attr2")); + Assert.Throws(() => reader.GetAttributeAsInt("attr3")); + Assert.Throws(() => reader.GetAttributeAsInt("Attr1")); + } + + [Test] + public static void GetAttributeAsBoolTest() + { + Assert.Inconclusive(); + } + + #endregion + + #region Recurse + + [Test] + public static void RecurseTest() + { + Assert.Inconclusive(); + } + + #endregion + + #region Skip + + [Test] + public static void SkipInsignificantWhitespaceTest() + { + Assert.Inconclusive(); + } + + [Test] + public static void SkipToNextElementTest() + { + Assert.Inconclusive(); + } + + #endregion + + #region Get Child Element + + [Test] + public static void HasChildElementsTest() + { + Assert.Inconclusive(); + } + + [Test] + public static void GetChildElementsTest() + { + Assert.Inconclusive(); + } + + [Test] + public static void GetChildElementsAsStringTest() + { + Assert.Inconclusive(); + } + + #endregion + + #region Read Element Content + + [Test] + public static void ReadElementContentAsByteTest() + { + Assert.Inconclusive(); + } + + [Test] + public static void ReadElementContentAsUintTest() + { + Assert.Inconclusive(); + } + + [Test] + public static void ReadElementContentAsIntTest() + { + Assert.Inconclusive(); + } + + [Test] + public static void ReadElementContentAsUShortTest() + { + Assert.Inconclusive(); + } + + [Test] + public static void ReadElementContentAsEnumTest() + { + Assert.Inconclusive(); + } + + #endregion + } +} diff --git a/ICD.Common.Utils.Tests/Xml/IcdXmlReaderTest.cs b/ICD.Common.Utils.Tests/Xml/IcdXmlReaderTest.cs index 25ae1c9..b099c89 100644 --- a/ICD.Common.Utils.Tests/Xml/IcdXmlReaderTest.cs +++ b/ICD.Common.Utils.Tests/Xml/IcdXmlReaderTest.cs @@ -48,7 +48,20 @@ namespace ICD.Common.Utils.Tests.Xml public void ValueTest() { - Assert.Inconclusive(); + IcdXmlReader reader = new IcdXmlReader("test"); + reader.SkipToNextElement(); + + Assert.AreEqual("test", reader.Value); + + reader = new IcdXmlReader(""); + reader.SkipToNextElement(); + + Assert.AreEqual("", reader.Value); + + reader = new IcdXmlReader(""); + reader.SkipToNextElement(); + + Assert.AreEqual(null, reader.Value); } public void NodeTypeTest() @@ -72,7 +85,12 @@ namespace ICD.Common.Utils.Tests.Xml public void GetAttributeTest() { - Assert.Inconclusive(); + IcdXmlReader reader = new IcdXmlReader(EXAMPLE_XML); + reader.SkipToNextElement(); + + Assert.AreEqual("1", reader.GetAttribute("attr1")); + Assert.AreEqual("2", reader.GetAttribute("attr2")); + Assert.AreEqual(null, reader.GetAttribute("attr3")); } public void ReadStringTest()