public void TestReversedUniqueIdSet() { UniqueId[] uids = { new UniqueId(20), new UniqueId(19), new UniqueId(15), new UniqueId(12), new UniqueId(11), new UniqueId(10), new UniqueId(9), new UniqueId(6), new UniqueId(5), new UniqueId(3), new UniqueId(2), new UniqueId(1) }; var list = new UniqueIdSet(uids); var actual = list.ToString(); Assert.AreEqual("20:19,15,12:9,6:5,3:1", actual, "Unexpected result for unsorted set."); list = new UniqueIdSet(uids, SortOrder.Ascending); actual = list.ToString(); Assert.AreEqual("1:3,5:6,9:12,15,19:20", actual, "Unexpected result for ascending set."); Assert.AreEqual(0, list.IndexOf(new UniqueId(1)), "Unexpected index for descending set."); list = new UniqueIdSet(uids, SortOrder.Descending); actual = list.ToString(); Assert.AreEqual("20:19,15,12:9,6:5,3:1", actual, "Unexpected result for descending set."); Assert.AreEqual(11, list.IndexOf(new UniqueId(1)), "Unexpected index for descending set."); }
public void TestArgumentExceptions() { var uids = new UniqueIdSet(SortOrder.Ascending); UniqueId uid; Assert.IsFalse(uids.IsReadOnly); uids.Add(UniqueId.MinValue); Assert.Throws <ArgumentOutOfRangeException> (() => new UniqueIdSet((SortOrder)500)); Assert.Throws <ArgumentException> (() => uids.Add(UniqueId.Invalid)); Assert.Throws <ArgumentNullException> (() => uids.AddRange(null)); Assert.Throws <ArgumentNullException> (() => uids.CopyTo(null, 0)); Assert.Throws <ArgumentOutOfRangeException> (() => uids.CopyTo(new UniqueId[1], -1)); Assert.Throws <ArgumentOutOfRangeException> (() => uids.RemoveAt(-1)); Assert.Throws <ArgumentOutOfRangeException> (() => uid = uids[-1]); Assert.Throws <NotSupportedException> (() => uids[0] = UniqueId.MinValue); Assert.Throws <NotSupportedException> (() => uids.Insert(0, UniqueId.MinValue)); var list = new List <UniqueId> { UniqueId.Invalid }; Assert.Throws <ArgumentNullException> (() => UniqueIdSet.ToString(null)); Assert.Throws <ArgumentException> (() => UniqueIdSet.ToString(list)); Assert.Throws <ArgumentNullException> (() => UniqueIdSet.TryParse(null, out uids)); }
public void TestNonSequentialUniqueIdSet() { UniqueId[] uids = { new UniqueId (1), new UniqueId (3), new UniqueId (5), new UniqueId (7), new UniqueId (9) }; var list = new UniqueIdSet (uids); var actual = list.ToString (); Assert.AreEqual ("1,3,5,7,9", actual); }
public void TestNonSequentialUniqueIdSet() { UniqueId[] uids = { new UniqueId(1), new UniqueId(3), new UniqueId(5), new UniqueId(7), new UniqueId(9) }; var list = new UniqueIdSet(uids); var actual = list.ToString(); Assert.AreEqual("1,3,5,7,9", actual); }
public void TestReversedUniqueIdSet() { UniqueId[] uids = { new UniqueId (20), new UniqueId (19), new UniqueId (15), new UniqueId (12), new UniqueId (11), new UniqueId (10), new UniqueId (9), new UniqueId (6), new UniqueId (5), new UniqueId (3), new UniqueId (2), new UniqueId (1) }; var list = new UniqueIdSet (uids); var actual = list.ToString (); Assert.AreEqual ("1:3,5:6,9:12,15,19:20", actual); }
public void TestMergingRangesDescending() { UniqueId[] uids = { new UniqueId(1), new UniqueId(2), new UniqueId(3), new UniqueId(5), new UniqueId(6), new UniqueId(7), new UniqueId(9), new UniqueId(10), new UniqueId(11), new UniqueId(4) }; var list = new UniqueIdSet(uids, SortOrder.Descending); var actual = list.ToString(); Assert.AreEqual("11:9,7:1", actual, "Unexpected result for sorted set."); }
public void TestComplexUniqueIdSet() { UniqueId[] uids = { new UniqueId(1), new UniqueId(2), new UniqueId(3), new UniqueId(5), new UniqueId(6), new UniqueId(9), new UniqueId(10), new UniqueId(11), new UniqueId(12), new UniqueId(15), new UniqueId(19), new UniqueId(20) }; var list = new UniqueIdSet(uids); var actual = list.ToString(); Assert.AreEqual("1:3,5:6,9:12,15,19:20", actual); }
public void TestReversedUniqueIdSet() { UniqueId[] uids = { new UniqueId(20), new UniqueId(19), new UniqueId(15), new UniqueId(12), new UniqueId(11), new UniqueId(10), new UniqueId(9), new UniqueId(6), new UniqueId(5), new UniqueId(3), new UniqueId(2), new UniqueId(1) }; var list = new UniqueIdSet(uids, false); var actual = list.ToString(); Assert.AreEqual("20:19,15,12:9,6:5,3:1", actual, "Unexpected result for unsorted set."); list = new UniqueIdSet(uids, true); actual = list.ToString(); Assert.AreEqual("1:3,5:6,9:12,15,19:20", actual, "Unexpected result for sorted set."); }
public void TestNonSequentialUniqueIdSet() { UniqueId[] uids = { new UniqueId(1), new UniqueId(3), new UniqueId(5), new UniqueId(7), new UniqueId(9) }; var list = new UniqueIdSet(uids); var actual = list.ToString(); Assert.AreEqual("1,3,5,7,9", actual); list = new UniqueIdSet(uids, SortOrder.Ascending); actual = list.ToString(); Assert.AreEqual("1,3,5,7,9", actual, "Unexpected result for ascending set."); list = new UniqueIdSet(uids, SortOrder.Descending); actual = list.ToString(); Assert.AreEqual("9,7,5,3,1", actual, "Unexpected result for descending set."); }
public void TestAscendingUniqueIdSet() { UniqueId[] uids = { new UniqueId(1), new UniqueId(2), new UniqueId(3), new UniqueId(4), new UniqueId(5), new UniqueId(6), new UniqueId(7), new UniqueId(8), new UniqueId(9) }; var list = new UniqueIdSet(uids, SortOrder.Ascending); var actual = list.ToString(); Assert.AreEqual("1:9", actual, "Incorrect initial value."); Assert.AreEqual(9, list.Count, "Incorrect initial count."); Assert.AreEqual(-1, list.IndexOf(new UniqueId(500))); Assert.IsFalse(list.Contains(new UniqueId(500))); Assert.IsFalse(list.Remove(new UniqueId(500))); // Test Remove() list.Remove(uids[0]); actual = list.ToString(); Assert.AreEqual("2:9", actual, "Incorrect results after Remove() #1."); Assert.AreEqual(8, list.Count, "Incorrect count after Remove() #1."); list.Remove(uids[uids.Length - 1]); actual = list.ToString(); Assert.AreEqual("2:8", actual, "Incorrect results after Remove() #2."); Assert.AreEqual(7, list.Count, "Incorrect count after Remove() #2."); list.Remove(uids[4]); actual = list.ToString(); Assert.AreEqual("2:4,6:8", actual, "Incorrect results after Remove() #3."); Assert.AreEqual(6, list.Count, "Incorrect count after Remove() #3."); // Test Add() list.Add(new UniqueId(5)); actual = list.ToString(); Assert.AreEqual("2:8", actual, "Incorrect results after Add() #1."); Assert.AreEqual(7, list.Count, "Incorrect count after Add() #1."); list.Add(new UniqueId(1)); actual = list.ToString(); Assert.AreEqual("1:8", actual, "Incorrect results after Add() #2."); Assert.AreEqual(8, list.Count, "Incorrect count after Add() #2."); list.Add(new UniqueId(9)); actual = list.ToString(); Assert.AreEqual("1:9", actual, "Incorrect results after Add() #3."); Assert.AreEqual(9, list.Count, "Incorrect count after Add() #3."); // Test RemoveAt() list.RemoveAt(0); actual = list.ToString(); Assert.AreEqual("2:9", actual, "Incorrect results after RemoveAt() #1."); Assert.AreEqual(8, list.Count, "Incorrect count after RemoveAt() #1."); list.RemoveAt(7); actual = list.ToString(); Assert.AreEqual("2:8", actual, "Incorrect results after RemoveAt() #2."); Assert.AreEqual(7, list.Count, "Incorrect count after RemoveAt() #2."); list.RemoveAt(3); actual = list.ToString(); Assert.AreEqual("2:4,6:8", actual, "Incorrect results after RemoveAt() #3."); Assert.AreEqual(6, list.Count, "Incorrect count after RemoveAt() #3."); // Test adding a range of items list.AddRange(uids); actual = list.ToString(); Assert.AreEqual("1:9", actual, "Incorrect results after AddRange()."); Assert.AreEqual(9, list.Count, "Incorrect count after AddRange()."); // Test clearing the list list.Clear(); Assert.AreEqual(0, list.Count, "Incorrect count after Clear()."); }
public void TestUnsortedUniqueIdSet() { UniqueId[] uids = { new UniqueId(1), new UniqueId(2), new UniqueId(3), new UniqueId(4), new UniqueId(5), new UniqueId(6), new UniqueId(7), new UniqueId(8), new UniqueId(9) }; var list = new UniqueIdSet(uids); var actual = list.ToString(); Assert.AreEqual("1:9", actual, "Incorrect initial value."); Assert.AreEqual(9, list.Count, "Incorrect initial count."); // Test Remove() list.Remove(uids[0]); actual = list.ToString(); Assert.AreEqual("2:9", actual, "Incorrect results after Remove() #1."); Assert.AreEqual(8, list.Count, "Incorrect count after Remove() #1."); list.Remove(uids[uids.Length - 1]); actual = list.ToString(); Assert.AreEqual("2:8", actual, "Incorrect results after Remove() #2."); Assert.AreEqual(7, list.Count, "Incorrect count after Remove() #2."); list.Remove(uids[4]); actual = list.ToString(); Assert.AreEqual("2:4,6:8", actual, "Incorrect results after Remove() #3."); Assert.AreEqual(6, list.Count, "Incorrect count after Remove() #3."); // Test Add() list.Add(new UniqueId(5)); actual = list.ToString(); Assert.AreEqual("2:4,6:8,5", actual, "Incorrect results after Add() #1."); Assert.AreEqual(7, list.Count, "Incorrect count after Add() #1."); list.Add(new UniqueId(1)); actual = list.ToString(); Assert.AreEqual("2:4,6:8,5,1", actual, "Incorrect results after Add() #2."); Assert.AreEqual(8, list.Count, "Incorrect count after Add() #2."); list.Add(new UniqueId(9)); actual = list.ToString(); Assert.AreEqual("2:4,6:8,5,1,9", actual, "Incorrect results after Add() #3."); Assert.AreEqual(9, list.Count, "Incorrect count after Add() #3."); // Test RemoveAt() list.RemoveAt(0); actual = list.ToString(); Assert.AreEqual("3:4,6:8,5,1,9", actual, "Incorrect results after RemoveAt() #1."); Assert.AreEqual(8, list.Count, "Incorrect count after RemoveAt() #1."); list.RemoveAt(7); actual = list.ToString(); Assert.AreEqual("3:4,6:8,5,1", actual, "Incorrect results after RemoveAt() #2."); Assert.AreEqual(7, list.Count, "Incorrect count after RemoveAt() #2."); list.RemoveAt(3); actual = list.ToString(); Assert.AreEqual("3:4,6,8,5,1", actual, "Incorrect results after RemoveAt() #3."); Assert.AreEqual(6, list.Count, "Incorrect count after RemoveAt() #3."); // Test adding a range of items list.AddRange(uids); actual = list.ToString(); Assert.AreEqual("3:4,6,8,5,1:2,7,9", actual, "Incorrect results after AddRange()."); Assert.AreEqual(9, list.Count, "Incorrect count after AddRange()."); // Test clearing the list list.Clear(); Assert.AreEqual(0, list.Count, "Incorrect count after Clear()."); }
public void TestSortedUniqueIdSet () { UniqueId[] uids = { new UniqueId (1), new UniqueId (2), new UniqueId (3), new UniqueId (4), new UniqueId (5), new UniqueId (6), new UniqueId (7), new UniqueId (8), new UniqueId (9) }; var list = new UniqueIdSet (uids, true); var actual = list.ToString (); Assert.AreEqual ("1:9", actual, "Incorrect initial value."); Assert.AreEqual (9, list.Count, "Incorrect initial count."); // Test Remove() list.Remove (uids[0]); actual = list.ToString (); Assert.AreEqual ("2:9", actual, "Incorrect results after Remove() #1."); Assert.AreEqual (8, list.Count, "Incorrect count after Remove() #1."); list.Remove (uids[uids.Length - 1]); actual = list.ToString (); Assert.AreEqual ("2:8", actual, "Incorrect results after Remove() #2."); Assert.AreEqual (7, list.Count, "Incorrect count after Remove() #2."); list.Remove (uids[4]); actual = list.ToString (); Assert.AreEqual ("2:4,6:8", actual, "Incorrect results after Remove() #3."); Assert.AreEqual (6, list.Count, "Incorrect count after Remove() #3."); // Test Add() list.Add (new UniqueId (5)); actual = list.ToString (); Assert.AreEqual ("2:8", actual, "Incorrect results after Add() #1."); Assert.AreEqual (7, list.Count, "Incorrect count after Add() #1."); list.Add (new UniqueId (1)); actual = list.ToString (); Assert.AreEqual ("1:8", actual, "Incorrect results after Add() #2."); Assert.AreEqual (8, list.Count, "Incorrect count after Add() #2."); list.Add (new UniqueId (9)); actual = list.ToString (); Assert.AreEqual ("1:9", actual, "Incorrect results after Add() #3."); Assert.AreEqual (9, list.Count, "Incorrect count after Add() #3."); // Test RemoveAt() list.RemoveAt (0); actual = list.ToString (); Assert.AreEqual ("2:9", actual, "Incorrect results after RemoveAt() #1."); Assert.AreEqual (8, list.Count, "Incorrect count after RemoveAt() #1."); list.RemoveAt (7); actual = list.ToString (); Assert.AreEqual ("2:8", actual, "Incorrect results after RemoveAt() #2."); Assert.AreEqual (7, list.Count, "Incorrect count after RemoveAt() #2."); list.RemoveAt (3); actual = list.ToString (); Assert.AreEqual ("2:4,6:8", actual, "Incorrect results after RemoveAt() #3."); Assert.AreEqual (6, list.Count, "Incorrect count after RemoveAt() #3."); // Test adding a range of items list.AddRange (uids); actual = list.ToString (); Assert.AreEqual ("1:9", actual, "Incorrect results after AddRange()."); Assert.AreEqual (9, list.Count, "Incorrect count after AddRange()."); // Test clearing the list list.Clear (); Assert.AreEqual (0, list.Count, "Incorrect count after Clear()."); }
public void TestReversedUniqueIdSet () { UniqueId[] uids = { new UniqueId (20), new UniqueId (19), new UniqueId (15), new UniqueId (12), new UniqueId (11), new UniqueId (10), new UniqueId (9), new UniqueId (6), new UniqueId (5), new UniqueId (3), new UniqueId (2), new UniqueId (1) }; var list = new UniqueIdSet (uids, false); var actual = list.ToString (); Assert.AreEqual ("20:19,15,12:9,6:5,3:1", actual, "Unexpected result for unsorted set."); list = new UniqueIdSet (uids, true); actual = list.ToString (); Assert.AreEqual ("1:3,5:6,9:12,15,19:20", actual, "Unexpected result for sorted set."); }
public void TestReversedUniqueIdSet () { UniqueId[] uids = { new UniqueId (20), new UniqueId (19), new UniqueId (15), new UniqueId (12), new UniqueId (11), new UniqueId (10), new UniqueId (9), new UniqueId (6), new UniqueId (5), new UniqueId (3), new UniqueId (2), new UniqueId (1) }; var list = new UniqueIdSet (uids); var actual = list.ToString (); Assert.AreEqual ("20:19,15,12:9,6:5,3:1", actual, "Unexpected result for unsorted set."); list = new UniqueIdSet (uids, SortOrder.Ascending); actual = list.ToString (); Assert.AreEqual ("1:3,5:6,9:12,15,19:20", actual, "Unexpected result for ascending set."); Assert.AreEqual (0, list.IndexOf (new UniqueId (1)), "Unexpected index for descending set."); list = new UniqueIdSet (uids, SortOrder.Descending); actual = list.ToString (); Assert.AreEqual ("20:19,15,12:9,6:5,3:1", actual, "Unexpected result for descending set."); Assert.AreEqual (11, list.IndexOf (new UniqueId (1)), "Unexpected index for descending set."); }
public void TestNonSequentialUniqueIdSet () { UniqueId[] uids = { new UniqueId (1), new UniqueId (3), new UniqueId (5), new UniqueId (7), new UniqueId (9) }; var list = new UniqueIdSet (uids); var actual = list.ToString (); Assert.AreEqual ("1,3,5,7,9", actual); list = new UniqueIdSet (uids, SortOrder.Ascending); actual = list.ToString (); Assert.AreEqual ("1,3,5,7,9", actual, "Unexpected result for ascending set."); list = new UniqueIdSet (uids, SortOrder.Descending); actual = list.ToString (); Assert.AreEqual ("9,7,5,3,1", actual, "Unexpected result for descending set."); }