mirror of
https://github.com/ICDSystems/ICD.Common.Utils.git
synced 2026-02-06 08:16:19 +00:00
Resurrecting old unit tests
This commit is contained in:
161
ICD.Common.Utils.Tests/Collections/IcdHashSetTest.cs
Normal file
161
ICD.Common.Utils.Tests/Collections/IcdHashSetTest.cs
Normal file
@@ -0,0 +1,161 @@
|
||||
using System;
|
||||
using NUnit.Framework;
|
||||
using ICD.Common.Properties;
|
||||
using ICD.Common.Utils.Collections;
|
||||
|
||||
namespace Icd.Common.Utils.Tests.Collections
|
||||
{
|
||||
[TestFixture]
|
||||
public sealed class IcdHashSetTest
|
||||
{
|
||||
[Test, UsedImplicitly]
|
||||
public void NullSetTest()
|
||||
{
|
||||
Assert.AreEqual(0, IcdHashSet<int>.NullSet.Count);
|
||||
}
|
||||
|
||||
[Test, UsedImplicitly]
|
||||
public void CountTest()
|
||||
{
|
||||
Assert.AreEqual(3, new IcdHashSet<int>(new[] {1, 2, 2, 3}).Count);
|
||||
}
|
||||
|
||||
[Test, UsedImplicitly]
|
||||
public void AddTest()
|
||||
{
|
||||
IcdHashSet<string> set = new IcdHashSet<string>();
|
||||
|
||||
Assert.IsTrue(set.Add("One"));
|
||||
Assert.IsFalse(set.Add("One"));
|
||||
|
||||
Assert.Throws<ArgumentNullException>(() => set.Add(null));
|
||||
}
|
||||
|
||||
[Test, UsedImplicitly]
|
||||
public void AddRangeTest()
|
||||
{
|
||||
IcdHashSet<int> set = new IcdHashSet<int>();
|
||||
|
||||
set.AddRange(new []{1, 2, 2, 3});
|
||||
|
||||
Assert.AreEqual(3, set.Count);
|
||||
}
|
||||
|
||||
[Test, UsedImplicitly]
|
||||
public void ClearTest()
|
||||
{
|
||||
IcdHashSet<int> set = new IcdHashSet<int>(new[] {1, 2, 2, 3});
|
||||
set.Clear();
|
||||
|
||||
Assert.AreEqual(0, set.Count);
|
||||
}
|
||||
|
||||
[Test, UsedImplicitly]
|
||||
public void ContainsTest()
|
||||
{
|
||||
IcdHashSet<int> set = new IcdHashSet<int>(new[] { 1, 2, 2, 3 });
|
||||
|
||||
Assert.IsTrue(set.Contains(1));
|
||||
Assert.IsTrue(set.Contains(2));
|
||||
Assert.IsTrue(set.Contains(3));
|
||||
Assert.IsFalse(set.Contains(4));
|
||||
}
|
||||
|
||||
[Test, UsedImplicitly]
|
||||
public void RemoveTest()
|
||||
{
|
||||
IcdHashSet<int> set = new IcdHashSet<int>(new[] { 1, 2, 2, 3 });
|
||||
set.Remove(2);
|
||||
|
||||
Assert.IsFalse(set.Contains(2));
|
||||
}
|
||||
|
||||
[Test, UsedImplicitly]
|
||||
public void UnionTest()
|
||||
{
|
||||
IcdHashSet<int> one = new IcdHashSet<int>(new[] { 1, 2 });
|
||||
IcdHashSet<int> two = new IcdHashSet<int>(new[] { 2, 3 });
|
||||
IcdHashSet<int> union = one.Union(two);
|
||||
|
||||
Assert.AreEqual(3, union.Count);
|
||||
}
|
||||
|
||||
[Test, UsedImplicitly]
|
||||
public void SubtractTest()
|
||||
{
|
||||
IcdHashSet<int> one = new IcdHashSet<int>(new[] { 1, 2 });
|
||||
IcdHashSet<int> two = new IcdHashSet<int>(new[] { 2, 3 });
|
||||
IcdHashSet<int> subtract = one.Subtract(two);
|
||||
|
||||
Assert.AreEqual(1, subtract.Count);
|
||||
Assert.IsTrue(subtract.Contains(1));
|
||||
}
|
||||
|
||||
[Test, UsedImplicitly]
|
||||
public void IsSubsetOfTest()
|
||||
{
|
||||
IcdHashSet<int> one = new IcdHashSet<int>(new[] { 1, 2 });
|
||||
IcdHashSet<int> two = new IcdHashSet<int>(new[] { 2, 3 });
|
||||
IcdHashSet<int> three = new IcdHashSet<int>(new[] { 1, 2, 3 });
|
||||
|
||||
Assert.IsFalse(one.IsSubsetOf(two));
|
||||
Assert.IsTrue(one.IsSubsetOf(three));
|
||||
}
|
||||
|
||||
[Test, UsedImplicitly]
|
||||
public void IntersectionTest()
|
||||
{
|
||||
IcdHashSet<int> one = new IcdHashSet<int>(new[] { 1, 2 });
|
||||
IcdHashSet<int> two = new IcdHashSet<int>(new[] { 2, 3 });
|
||||
IcdHashSet<int> intersection = one.Intersection(two);
|
||||
|
||||
Assert.AreEqual(1, intersection.Count);
|
||||
Assert.IsTrue(intersection.Contains(2));
|
||||
}
|
||||
|
||||
[Test, UsedImplicitly]
|
||||
public void NonIntersectionTest()
|
||||
{
|
||||
IcdHashSet<int> one = new IcdHashSet<int>(new[] { 1, 2 });
|
||||
IcdHashSet<int> two = new IcdHashSet<int>(new[] { 2, 3 });
|
||||
IcdHashSet<int> nonIntersection = one.NonIntersection(two);
|
||||
|
||||
Assert.AreEqual(2, nonIntersection.Count);
|
||||
Assert.IsTrue(nonIntersection.Contains(1));
|
||||
Assert.IsTrue(nonIntersection.Contains(3));
|
||||
}
|
||||
|
||||
[Test, UsedImplicitly]
|
||||
public void IsProperSubsetOfTest()
|
||||
{
|
||||
IcdHashSet<int> one = new IcdHashSet<int>(new[] { 1, 2 });
|
||||
IcdHashSet<int> two = new IcdHashSet<int>(new[] { 1, 2 });
|
||||
IcdHashSet<int> three = new IcdHashSet<int>(new[] { 1, 2, 3 });
|
||||
|
||||
Assert.IsFalse(one.IsProperSubsetOf(two));
|
||||
Assert.IsTrue(one.IsProperSubsetOf(three));
|
||||
}
|
||||
|
||||
[Test, UsedImplicitly]
|
||||
public void IsSupersetOfTest()
|
||||
{
|
||||
IcdHashSet<int> one = new IcdHashSet<int>(new[] { 1, 2 });
|
||||
IcdHashSet<int> two = new IcdHashSet<int>(new[] { 2, 3 });
|
||||
IcdHashSet<int> three = new IcdHashSet<int>(new[] { 1, 2, 3 });
|
||||
|
||||
Assert.IsFalse(two.IsSupersetOf(one));
|
||||
Assert.IsTrue(three.IsSupersetOf(one));
|
||||
}
|
||||
|
||||
[Test, UsedImplicitly]
|
||||
public void IsProperSupersetOfTest()
|
||||
{
|
||||
IcdHashSet<int> one = new IcdHashSet<int>(new[] { 1, 2 });
|
||||
IcdHashSet<int> two = new IcdHashSet<int>(new[] { 1, 2 });
|
||||
IcdHashSet<int> three = new IcdHashSet<int>(new[] { 1, 2, 3 });
|
||||
|
||||
Assert.IsFalse(two.IsProperSupersetOf(one));
|
||||
Assert.IsTrue(three.IsProperSupersetOf(one));
|
||||
}
|
||||
}
|
||||
}
|
||||
80
ICD.Common.Utils.Tests/Collections/ScrollQueueTest.cs
Normal file
80
ICD.Common.Utils.Tests/Collections/ScrollQueueTest.cs
Normal file
@@ -0,0 +1,80 @@
|
||||
using System.Linq;
|
||||
using NUnit.Framework;
|
||||
using ICD.Common.Properties;
|
||||
using ICD.Common.Utils.Collections;
|
||||
|
||||
namespace ICD.Common.Utils.Tests.Collections
|
||||
{
|
||||
[TestFixture]
|
||||
public sealed class ScrollQueueTest
|
||||
{
|
||||
[Test, UsedImplicitly]
|
||||
public void MaxSizeTest()
|
||||
{
|
||||
ScrollQueue<int> test = new ScrollQueue<int>(5);
|
||||
test.Enqueue(0);
|
||||
test.Enqueue(1);
|
||||
test.Enqueue(2);
|
||||
test.Enqueue(3);
|
||||
test.Enqueue(4);
|
||||
|
||||
Assert.AreEqual(5, test.Count);
|
||||
|
||||
test.MaxSize = 3;
|
||||
|
||||
Assert.AreEqual(3, test.Count);
|
||||
Assert.AreEqual(2, test.Peek());
|
||||
|
||||
test.Enqueue(0);
|
||||
|
||||
Assert.AreEqual(3, test.Count);
|
||||
Assert.AreEqual(3, test.Peek());
|
||||
}
|
||||
|
||||
[Test, UsedImplicitly]
|
||||
public void ClearTest()
|
||||
{
|
||||
ScrollQueue<int> test = new ScrollQueue<int>(5);
|
||||
test.Enqueue(0);
|
||||
test.Clear();
|
||||
|
||||
Assert.AreEqual(0, test.Count);
|
||||
}
|
||||
|
||||
[Test, UsedImplicitly]
|
||||
public void EnqueueTest()
|
||||
{
|
||||
ScrollQueue<int> test = new ScrollQueue<int>(5);
|
||||
test.Enqueue(0);
|
||||
test.Enqueue(1);
|
||||
|
||||
Assert.AreEqual(2, test.Count);
|
||||
|
||||
int[] array = test.ToArray();
|
||||
|
||||
Assert.AreEqual(0, array[0]);
|
||||
Assert.AreEqual(1, array[1]);
|
||||
}
|
||||
|
||||
[Test, UsedImplicitly]
|
||||
public void DequeueTest()
|
||||
{
|
||||
ScrollQueue<int> test = new ScrollQueue<int>(5);
|
||||
test.Enqueue(0);
|
||||
test.Enqueue(1);
|
||||
|
||||
Assert.AreEqual(0, test.Dequeue());
|
||||
Assert.AreEqual(1, test.Count);
|
||||
}
|
||||
|
||||
[Test, UsedImplicitly]
|
||||
public void PeekTest()
|
||||
{
|
||||
ScrollQueue<int> test = new ScrollQueue<int>(5);
|
||||
test.Enqueue(0);
|
||||
test.Enqueue(1);
|
||||
|
||||
Assert.AreEqual(0, test.Peek());
|
||||
}
|
||||
}
|
||||
}
|
||||
37
ICD.Common.Utils.Tests/MathUtilsTest.cs
Normal file
37
ICD.Common.Utils.Tests/MathUtilsTest.cs
Normal file
@@ -0,0 +1,37 @@
|
||||
using ICD.Common.Properties;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace ICD.Common.Utils.Tests
|
||||
{
|
||||
[TestFixture]
|
||||
public sealed class MathUtilsTest
|
||||
{
|
||||
[Test, UsedImplicitly]
|
||||
public void ClampTest()
|
||||
{
|
||||
Assert.AreEqual(MathUtils.Clamp(-10, 0, 0), 0);
|
||||
Assert.AreEqual(MathUtils.Clamp(-10, 10, 0), 0);
|
||||
Assert.AreEqual(MathUtils.Clamp(-10, 0, 10), 0);
|
||||
|
||||
Assert.AreEqual(MathUtils.Clamp(0, 0, 0), 0);
|
||||
Assert.AreEqual(MathUtils.Clamp(0, 10, 0), 0);
|
||||
Assert.AreEqual(MathUtils.Clamp(0, 0, 10), 0);
|
||||
|
||||
Assert.AreEqual(MathUtils.Clamp(20, 0, 10), 10);
|
||||
Assert.AreEqual(MathUtils.Clamp(20, 10, 0), 10);
|
||||
Assert.AreEqual(MathUtils.Clamp(20, 10, 10), 10);
|
||||
}
|
||||
|
||||
[Test, UsedImplicitly]
|
||||
public void MapRangeTest()
|
||||
{
|
||||
Assert.AreEqual(0, MathUtils.MapRange(0, 100, 0, 10, 0));
|
||||
Assert.AreEqual(5, MathUtils.MapRange(0, 100, 0, 10, 50));
|
||||
Assert.AreEqual(10, MathUtils.MapRange(0, 100, 0, 10, 100));
|
||||
|
||||
Assert.AreEqual(0, MathUtils.MapRange(0, 10, 0, 100, 0));
|
||||
Assert.AreEqual(50, MathUtils.MapRange(0, 10, 0, 100, 5));
|
||||
Assert.AreEqual(100, MathUtils.MapRange(0, 10, 0, 100, 10));
|
||||
}
|
||||
}
|
||||
}
|
||||
25
ICD.Common.Utils.Tests/PathUtilsTest.cs
Normal file
25
ICD.Common.Utils.Tests/PathUtilsTest.cs
Normal file
@@ -0,0 +1,25 @@
|
||||
using System.Linq;
|
||||
using NUnit.Framework;
|
||||
using ICD.Common.Utils;
|
||||
using ICD.Common.Properties;
|
||||
#if SIMPLSHARP
|
||||
using Crestron.IO;
|
||||
#else
|
||||
using System.IO;
|
||||
#endif
|
||||
|
||||
namespace RSD.SimplSharp.Common.Interfaces.Tests.Utils
|
||||
{
|
||||
[TestFixture]
|
||||
public sealed class PathUtilsTest
|
||||
{
|
||||
[Test, UsedImplicitly]
|
||||
public void JoinTest()
|
||||
{
|
||||
string expected = Path.Combine("A", "B");
|
||||
expected = Path.Combine(expected, "C");
|
||||
|
||||
Assert.AreEqual(expected, PathUtils.Join("A", "B", "C"));
|
||||
}
|
||||
}
|
||||
}
|
||||
82
ICD.Common.Utils.Tests/StringUtilsTest.cs
Normal file
82
ICD.Common.Utils.Tests/StringUtilsTest.cs
Normal file
@@ -0,0 +1,82 @@
|
||||
using ICD.Common.Properties;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace ICD.Common.Utils.Tests
|
||||
{
|
||||
[TestFixture]
|
||||
public sealed class StringUtilsTest
|
||||
{
|
||||
[Test, UsedImplicitly]
|
||||
public void ToHexLiteralTest()
|
||||
{
|
||||
const string hex = "\x08\x22\x00\x00\x00\x02";
|
||||
string output = StringUtils.ToHexLiteral(hex);
|
||||
|
||||
Assert.AreEqual(@"\x08\x22\x00\x00\x00\x02", output);
|
||||
}
|
||||
|
||||
[Test, UsedImplicitly]
|
||||
public void FromHexLiteralTest()
|
||||
{
|
||||
const string literal = @"\x08\x22\x00\x00\x00\x02";
|
||||
string output = StringUtils.FromHexLiteral(literal);
|
||||
|
||||
Assert.AreEqual("\x08\x22\x00\x00\x00\x02", output);
|
||||
}
|
||||
|
||||
[Test, UsedImplicitly]
|
||||
public void NiceNameTest()
|
||||
{
|
||||
string output = StringUtils.NiceName("TodayILiveInTheUSAWithSimon");
|
||||
Assert.AreEqual("Today I Live In The USA With Simon", output);
|
||||
}
|
||||
|
||||
[Test, UsedImplicitly]
|
||||
public void SafeNumericFormatTest()
|
||||
{
|
||||
Assert.AreEqual(string.Empty, StringUtils.SafeNumericFormat("# # ###.###.####", string.Empty));
|
||||
Assert.AreEqual("9 1 252.943.4324", StringUtils.SafeNumericFormat("# # ###.###.####", "0000912529434324"));
|
||||
Assert.AreEqual("9 1 252.943.4324", StringUtils.SafeNumericFormat("# # ###.###.####", "912529434324"));
|
||||
Assert.AreEqual("1 252.943.4324", StringUtils.SafeNumericFormat("# # ###.###.####", "12529434324"));
|
||||
Assert.AreEqual("252.943.4324", StringUtils.SafeNumericFormat("# # ###.###.####", "2529434324"));
|
||||
Assert.AreEqual("052.943.4324", StringUtils.SafeNumericFormat("# # ###.###.####", "0529434324"));
|
||||
}
|
||||
|
||||
[Test, UsedImplicitly]
|
||||
public void ReverseTest()
|
||||
{
|
||||
Assert.AreEqual("rabooF", StringUtils.Reverse("Foobar"));
|
||||
}
|
||||
|
||||
[Test, UsedImplicitly]
|
||||
public void ArrayFormatTest()
|
||||
{
|
||||
int[] items = {1, 4, 3, 2, 5};
|
||||
Assert.AreEqual("[1, 4, 3, 2, 5]", StringUtils.ArrayFormat(items));
|
||||
}
|
||||
|
||||
[Test, UsedImplicitly]
|
||||
public void RangeFormatTest()
|
||||
{
|
||||
Assert.AreEqual("[-3 - 5]", StringUtils.RangeFormat(-3, 5));
|
||||
}
|
||||
|
||||
[Test, UsedImplicitly]
|
||||
public void UppercaseFirstTest()
|
||||
{
|
||||
Assert.AreEqual("Foobar", StringUtils.UppercaseFirst("foobar"));
|
||||
}
|
||||
|
||||
[Test, UsedImplicitly]
|
||||
public void ToIpIdStringTest()
|
||||
{
|
||||
Assert.AreEqual("0x67", StringUtils.ToIpIdString(0x67));
|
||||
}
|
||||
|
||||
[Test, UsedImplicitly]
|
||||
public void FromIpIdStringTest()
|
||||
{
|
||||
Assert.AreEqual(0x67, StringUtils.FromIpIdString("0x67"));
|
||||
}
|
||||
}
|
||||
}
|
||||
17
ICD.Common.Utils.Tests/Xml/IcdXmlAttributeTest.cs
Normal file
17
ICD.Common.Utils.Tests/Xml/IcdXmlAttributeTest.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
using ICD.Common.Properties;
|
||||
using ICD.Common.Utils.Xml;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace ICD.Common.Utils.Tests.Xml
|
||||
{
|
||||
[TestFixture]
|
||||
public sealed class IcdXmlAttributeTest
|
||||
{
|
||||
[Test, UsedImplicitly]
|
||||
public void ValueAsIntTest()
|
||||
{
|
||||
IcdXmlAttribute attribute = new IcdXmlAttribute("test", "12");
|
||||
Assert.AreEqual("12", attribute.Value);
|
||||
}
|
||||
}
|
||||
}
|
||||
164
ICD.Common.Utils.Tests/Xml/XmlUtilsTest.cs
Normal file
164
ICD.Common.Utils.Tests/Xml/XmlUtilsTest.cs
Normal file
@@ -0,0 +1,164 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using NUnit.Framework;
|
||||
using ICD.Common.Properties;
|
||||
using ICD.Common.Utils.Xml;
|
||||
#if SIMPLSHARP
|
||||
using Crestron.Xml;
|
||||
#else
|
||||
using System.Xml;
|
||||
#endif
|
||||
|
||||
namespace ICD.Common.Utils.Tests.Xml
|
||||
{
|
||||
[TestFixture]
|
||||
public sealed class XmlUtilsTest
|
||||
{
|
||||
// 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>";
|
||||
|
||||
[Test, UsedImplicitly]
|
||||
public void GetAttributesTest()
|
||||
{
|
||||
using (IcdXmlReader reader = new IcdXmlReader(EXAMPLE_XML))
|
||||
{
|
||||
reader.SkipToNextElement();
|
||||
|
||||
IcdXmlAttribute[] attributes = reader.GetAttributes().ToArray();
|
||||
|
||||
Assert.AreEqual(2, attributes.Length);
|
||||
Assert.AreEqual("attr1", attributes[0].Name);
|
||||
Assert.AreEqual("1", attributes[0].Value);
|
||||
Assert.AreEqual("attr2", attributes[1].Name);
|
||||
Assert.AreEqual("2", attributes[1].Value);
|
||||
}
|
||||
}
|
||||
|
||||
[Test, UsedImplicitly]
|
||||
public void GetAttributeAsIntTest()
|
||||
{
|
||||
using (IcdXmlReader reader = new IcdXmlReader(EXAMPLE_XML))
|
||||
{
|
||||
reader.SkipToNextElement();
|
||||
|
||||
int value = reader.GetAttributeAsInt("attr1");
|
||||
Assert.AreEqual(1, value);
|
||||
}
|
||||
}
|
||||
|
||||
[Test, UsedImplicitly]
|
||||
public void RecursionTest()
|
||||
{
|
||||
List<string[]> paths = new List<string[]>();
|
||||
List<string> nodes = new List<string>();
|
||||
|
||||
XmlUtils.Recurse(EXAMPLE_XML, args =>
|
||||
{
|
||||
paths.Add(args.Path);
|
||||
nodes.Add(args.Outer);
|
||||
}
|
||||
);
|
||||
|
||||
Assert.AreEqual(4, paths.Count);
|
||||
|
||||
Assert.AreEqual("Level1", paths[0][0]);
|
||||
Assert.AreEqual("Level2", paths[1][1]);
|
||||
Assert.AreEqual("Level2", paths[2][1]);
|
||||
Assert.AreEqual("Level3", paths[3][2]);
|
||||
|
||||
using (IcdXmlReader reader = new IcdXmlReader(nodes[3]))
|
||||
{
|
||||
reader.SkipToNextElement();
|
||||
Assert.AreEqual("Some text", reader.ReadInnerXml());
|
||||
}
|
||||
}
|
||||
|
||||
[Test, UsedImplicitly]
|
||||
public void SkipInsignificantWhitespaceTest()
|
||||
{
|
||||
using (IcdXmlReader reader = new IcdXmlReader(EXAMPLE_XML))
|
||||
{
|
||||
reader.Read();
|
||||
Assert.AreEqual(reader.NodeType, XmlNodeType.Whitespace);
|
||||
|
||||
reader.SkipInsignificantWhitespace();
|
||||
Assert.AreNotEqual(reader.NodeType, XmlNodeType.Whitespace);
|
||||
}
|
||||
}
|
||||
|
||||
[Test, UsedImplicitly]
|
||||
public void SkipToNextElementTest()
|
||||
{
|
||||
using (IcdXmlReader reader = new IcdXmlReader(EXAMPLE_XML))
|
||||
{
|
||||
reader.SkipToNextElement();
|
||||
Assert.AreEqual("Level1", reader.Name);
|
||||
|
||||
reader.SkipToNextElement();
|
||||
Assert.AreEqual("Level2", reader.Name);
|
||||
}
|
||||
}
|
||||
|
||||
[Test, UsedImplicitly]
|
||||
public void GetChildElementsFromXmlTest()
|
||||
{
|
||||
IEnumerable<IcdXmlReader> results = XmlUtils.GetChildElements(EXAMPLE_XML);
|
||||
IcdXmlReader[] children = results.ToArray();
|
||||
|
||||
Assert.AreEqual(2, children.Length);
|
||||
Assert.AreEqual("Level2", children[0].Name);
|
||||
Assert.AreEqual("Level2", children[1].Name);
|
||||
|
||||
foreach (IcdXmlReader child in children)
|
||||
child.Dispose();
|
||||
}
|
||||
|
||||
[Test, UsedImplicitly]
|
||||
public void GetChildElementsAsStringEmptyElementTest()
|
||||
{
|
||||
string[] results = XmlUtils.GetChildElementsAsString(EXAMPLE_XML_2).ToArray();
|
||||
|
||||
Assert.AreEqual(2, results.Length);
|
||||
Assert.AreEqual("<Level2 />", results[0]);
|
||||
Assert.AreEqual("<Level2 />", results[1]);
|
||||
}
|
||||
|
||||
[Test, UsedImplicitly]
|
||||
public void GetChildElementsTest()
|
||||
{
|
||||
using (IcdXmlReader reader = new IcdXmlReader(EXAMPLE_XML))
|
||||
{
|
||||
reader.SkipToNextElement();
|
||||
|
||||
IEnumerable<IcdXmlReader> results = reader.GetChildElements();
|
||||
IcdXmlReader[] children = results.ToArray();
|
||||
|
||||
Assert.AreEqual(2, children.Length);
|
||||
Assert.AreEqual("Level2", children[0].Name);
|
||||
Assert.AreEqual("Level2", children[1].Name);
|
||||
|
||||
foreach (IcdXmlReader child in children)
|
||||
child.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
[Test, UsedImplicitly]
|
||||
public void IsValidXmlTest()
|
||||
{
|
||||
Assert.IsFalse(XmlUtils.IsValidXml(@"<Foo></Bar>"));
|
||||
Assert.IsTrue(XmlUtils.IsValidXml(EXAMPLE_XML));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user