Initial commit of ListExtensionsTest

This commit is contained in:
Chris Cameron
2017-07-28 12:07:43 -04:00
parent f77c2cafd7
commit 90477a8189

View File

@@ -0,0 +1,54 @@
using ICD.Common.Utils.Extensions;
using NUnit.Framework;
using System.Collections.Generic;
using System;
namespace ICD.Common.Utils.Tests_NetStandard.Extensions
{
[TestFixture]
public sealed class ListExtensionsTest
{
[Test]
public void AddSortedTest()
{
List<int> testList = new List<int>();
testList.AddSorted(2);
testList.AddSorted(3);
testList.AddSorted(1);
testList.AddSorted(2);
Assert.AreEqual(4, testList.Count);
Assert.AreEqual(1, testList[0]);
Assert.AreEqual(2, testList[1]);
Assert.AreEqual(2, testList[2]);
Assert.AreEqual(3, testList[3]);
}
[Test]
public void AddSortedComparerTest()
{
List<int> testList = new List<int>();
IComparer<int> comparer = new InverseComparer();
testList.AddSorted(2, comparer);
testList.AddSorted(3, comparer);
testList.AddSorted(1, comparer);
testList.AddSorted(2, comparer);
Assert.AreEqual(4, testList.Count);
Assert.AreEqual(3, testList[0]);
Assert.AreEqual(2, testList[1]);
Assert.AreEqual(2, testList[2]);
Assert.AreEqual(1, testList[3]);
}
internal class InverseComparer : IComparer<int>
{
public int Compare(int x, int y)
{
return y.CompareTo(x);
}
}
}
}