mirror of
https://github.com/ICDSystems/ICD.Common.Utils.git
synced 2026-02-15 12:45:01 +00:00
Additional unit tests and test stubs
This commit is contained in:
14
ICD.Common.Utils.Tests/Extensions/AssemblyExtensionsTest.cs
Normal file
14
ICD.Common.Utils.Tests/Extensions/AssemblyExtensionsTest.cs
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
using NUnit.Framework;
|
||||||
|
|
||||||
|
namespace ICD.Common.Utils.Tests.Extensions
|
||||||
|
{
|
||||||
|
[TestFixture]
|
||||||
|
public sealed class AssemblyExtensionsTest
|
||||||
|
{
|
||||||
|
[Test]
|
||||||
|
public void GetPathTest()
|
||||||
|
{
|
||||||
|
Assert.Inconclusive();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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<int> a = new List<int> {1, 2, 2, 3};
|
||||||
|
List<int> b = new List<int> {2, 3};
|
||||||
|
|
||||||
|
((ICollection<int>)a).RemoveAll(i => b.Contains(i));
|
||||||
|
|
||||||
|
Assert.AreEqual(1, a.Count);
|
||||||
|
Assert.AreEqual(1, a[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void RemoveAllOtherTest()
|
||||||
|
{
|
||||||
|
List<int> a = new List<int> {1, 2, 2, 3};
|
||||||
|
List<int> b = new List<int> {2, 3};
|
||||||
|
|
||||||
|
a.RemoveAll(b);
|
||||||
|
|
||||||
|
Assert.AreEqual(1, a.Count);
|
||||||
|
Assert.AreEqual(1, a[0]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
20
ICD.Common.Utils.Tests/Extensions/DateTimeExtensionsTest.cs
Normal file
20
ICD.Common.Utils.Tests/Extensions/DateTimeExtensionsTest.cs
Normal file
@@ -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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
26
ICD.Common.Utils.Tests/Extensions/EnumExtensionsTest.cs
Normal file
26
ICD.Common.Utils.Tests/Extensions/EnumExtensionsTest.cs
Normal file
@@ -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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
178
ICD.Common.Utils.Tests/Extensions/XmlReaderExtensionsTest.cs
Normal file
178
ICD.Common.Utils.Tests/Extensions/XmlReaderExtensionsTest.cs
Normal file
@@ -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 = " <Level1 attr1=\"1\" attr2=\"2\"> "
|
||||||
|
+ " <Level2> "
|
||||||
|
+ " </Level2> "
|
||||||
|
+ " <Level2> "
|
||||||
|
+ " <Level3>Some text</Level3> "
|
||||||
|
+ " </Level2> "
|
||||||
|
+ " </Level1> ";
|
||||||
|
|
||||||
|
// For testing empty elements
|
||||||
|
private const string EXAMPLE_XML_2 = "<Level1>"
|
||||||
|
+ "<Level2 />"
|
||||||
|
+ "<Level2 />"
|
||||||
|
+ "</Level1>";
|
||||||
|
|
||||||
|
#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<FormatException>(() => reader.GetAttributeAsString("attr1"));
|
||||||
|
|
||||||
|
reader.SkipToNextElement();
|
||||||
|
|
||||||
|
Assert.AreEqual("1", reader.GetAttributeAsString("attr1"));
|
||||||
|
Assert.AreEqual("2", reader.GetAttributeAsString("attr2"));
|
||||||
|
Assert.Throws<FormatException>(() => reader.GetAttributeAsString("attr3"));
|
||||||
|
Assert.Throws<FormatException>(() => reader.GetAttributeAsString("Attr1"));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public static void GetAttributeAsIntTest()
|
||||||
|
{
|
||||||
|
IcdXmlReader reader = new IcdXmlReader(EXAMPLE_XML);
|
||||||
|
|
||||||
|
Assert.Throws<FormatException>(() => reader.GetAttributeAsInt("attr1"));
|
||||||
|
|
||||||
|
reader.SkipToNextElement();
|
||||||
|
|
||||||
|
Assert.AreEqual(1, reader.GetAttributeAsInt("attr1"));
|
||||||
|
Assert.AreEqual(2, reader.GetAttributeAsInt("attr2"));
|
||||||
|
Assert.Throws<FormatException>(() => reader.GetAttributeAsInt("attr3"));
|
||||||
|
Assert.Throws<FormatException>(() => 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
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -48,7 +48,20 @@ namespace ICD.Common.Utils.Tests.Xml
|
|||||||
|
|
||||||
public void ValueTest()
|
public void ValueTest()
|
||||||
{
|
{
|
||||||
Assert.Inconclusive();
|
IcdXmlReader reader = new IcdXmlReader("<Test>test</Test>");
|
||||||
|
reader.SkipToNextElement();
|
||||||
|
|
||||||
|
Assert.AreEqual("test", reader.Value);
|
||||||
|
|
||||||
|
reader = new IcdXmlReader("<Test></Test>");
|
||||||
|
reader.SkipToNextElement();
|
||||||
|
|
||||||
|
Assert.AreEqual("", reader.Value);
|
||||||
|
|
||||||
|
reader = new IcdXmlReader("<Test />");
|
||||||
|
reader.SkipToNextElement();
|
||||||
|
|
||||||
|
Assert.AreEqual(null, reader.Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void NodeTypeTest()
|
public void NodeTypeTest()
|
||||||
@@ -72,7 +85,12 @@ namespace ICD.Common.Utils.Tests.Xml
|
|||||||
|
|
||||||
public void GetAttributeTest()
|
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()
|
public void ReadStringTest()
|
||||||
|
|||||||
Reference in New Issue
Block a user