public void Insert_InvalidIndex_IndexOutOfRangeException() { // Arrange int itemsToAdd = 40; int index = 40; JList <int> j = new JList <int>(); for (int i = 0; i < itemsToAdd; i++) { j.Add(i); } // Act j.Insert(index, 100); // Assert }
public void Insert_ValidIndex_ValueAtLeftRemainsSame() { // Arrange int itemsToAdd = 40; int index = 19; JList <int> j = new JList <int>(); for (int i = 0; i < itemsToAdd; i++) { j.Add(i); } // Act int expected = j[index - 1]; j.Insert(index, 100); // Assert int actual = j[index - 1]; Assert.AreEqual(expected, actual); }
public void Insert_ValidIndex_ValueAppearsAtSpecifiedIndex() { // Arrange int itemsToAdd = 40; int index = 19; JList <int> j = new JList <int>(); for (int i = 0; i < itemsToAdd; i++) { j.Add(i); } // Act int expected = 100; j.Insert(index, expected); // Assert int actual = j[index]; Assert.AreEqual(expected, actual); }
public void Insert_ValidIndex_CountIncreases() { // Arrange int itemsToAdd = 40; int index = 19; JList <int> j = new JList <int>(); for (int i = 0; i < itemsToAdd; i++) { j.Add(i); } // Act int expected = j.Count + 1; j.Insert(index, 100); // Assert int actual = j.Count; Assert.AreEqual(expected, actual); }