public void TestCount() { int[] source1 = new int[] { 7, 6, 4 }; int[] source2 = new int[] { 7, 6, 4, 3, 2, 6 }; IList<int> adapterForSource1 = new ArrayToListAdapter<int>(source1); IList<int> adapterForSource2 = new ArrayToListAdapter<int>(source2); Assert.AreEqual(source1.Length, adapterForSource1.Count); Assert.AreEqual(source2.Length, adapterForSource2.Count); }
public void TestClear() { int[] source = new int[] { 7, 6, 4, 3, 2, 6 }; IList<int> adapter = new ArrayToListAdapter<int>(source); adapter.Clear(); Assert.AreEqual(0, adapter.Count); }
public void TestContains() { int[] source = new int[] { 7, 6, 4, 3, 2, 6 }; IList<int> adapter = new ArrayToListAdapter<int>(source); Assert.IsTrue(adapter.Contains(7)); Assert.IsTrue(adapter.Contains(6)); Assert.IsTrue(adapter.Contains(3)); Assert.IsFalse(adapter.Contains(5)); }
public void TestAdd() { int[] source = new int[] { 7, 6, 4, 3, 2, 6 }; IList<int> adapter = new ArrayToListAdapter<int>(source); adapter.Add(100); Assert.AreEqual(source.Length + 1, adapter.Count); Assert.AreEqual(100, adapter[adapter.Count - 1]); }
public void TestCopyTo() { int[] source = new int[] { 7, 6, 4, 3, 2, 6 }; int[] destination = new int[source.Length]; IList<int> adapter = new ArrayToListAdapter<int>(source); adapter.CopyTo(destination, 0); for (int i = 0; i < source.Length; i++) { Assert.AreEqual(source[i], destination[i]); } }
public void TestEnumeratorGeneric() { int[] source = new int[] { 7, 6, 4, 3, 2, 6 }; IList<int> adapter = new ArrayToListAdapter<int>(source); IEnumerator<int> enumerator = adapter.GetEnumerator(); int counter = 0; while (enumerator.MoveNext()) { Assert.AreEqual(source[counter], enumerator.Current); counter++; } }
public void TestRemoveAt() { int[] source = new int[] { 7, 6, 4, 3, 2, 6 }; int[] sourceAfterRemove = new int[] { 7, 6, 3, 2, 6 }; IList<int> adapter = new ArrayToListAdapter<int>(source); adapter.RemoveAt(2); for (int i = 0; i < sourceAfterRemove.Length; i++) { Assert.AreEqual(sourceAfterRemove[i], adapter[i]); } }
public void TestIsReadonly() { int[] source = new int[] { 7, 6, 4, 3, 2, 6 }; IList<int> adapter = new ArrayToListAdapter<int>(source); Assert.IsFalse(adapter.IsReadOnly); }
public void TestInsert() { int[] source = new int[] { 7, 6, 4, 3, 2, 6 }; int[] sourceAfterInsert = new int[] { 7, 6, 1, 4, 3, 2, 6 }; IList<int> adapter = new ArrayToListAdapter<int>(source); adapter.Insert(2, 1); for (int i = 0; i < sourceAfterInsert.Length; i++) { Assert.AreEqual(sourceAfterInsert[i], adapter[i]); } }
public void TestIndexOf() { int[] source = new int[] { 7, 6, 4, 3, 2, 6 }; IList<int> adapter = new ArrayToListAdapter<int>(source); Assert.AreEqual(0, adapter.IndexOf(7)); Assert.AreEqual(1, adapter.IndexOf(6)); Assert.AreEqual(3, adapter.IndexOf(3)); Assert.AreEqual(-1, adapter.IndexOf(5)); }
public void TestGetterAndSetter() { int[] source = new int[] { 7, 6, 4, 3, 2, 6 }; IList<int> adapter = new ArrayToListAdapter<int>(source); for (int i = 0; i < source.Length; i++) { adapter[i] = i; Assert.AreEqual(i, adapter[i]); } }