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 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 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()."); }