public void ShouldCreateNewVectorWithAlteredCell() { Vector <int> original = new ArrayVector <int>(1, 2, 3); original.ShouldList(1, 2, 3); original.With(0, 10).ShouldList(10, 2, 3); original.With(1, 20).ShouldList(1, 20, 3); original.With(2, 30).ShouldList(1, 2, 30); original.ShouldList(1, 2, 3); }
public void ShouldThrowExceptionWhenGivenIndexIsOutOfRange() { Vector <int> empty = new ArrayVector <int>(); var actions = new Action[] { () => empty.With(0, 0), () => empty.With(-1, -1), () => { int value = empty[0]; }, () => { int value = empty[-1]; } }; foreach (var action in actions) { action.ShouldThrow <IndexOutOfRangeException>("Index was outside the bounds of the vector."); } }