public void LastIndexOfChokesOnBadIndex(Position position) { var index = PositionToIndex(position); var sut = new CopyOnWriteList <T>(Samples); Assert.Catch <ArgumentOutOfRangeException>(() => sut.LastIndexOf(TestData <T> .One, index)); Assert.Catch <ArgumentOutOfRangeException>(() => sut.LastIndexOf(TestData <T> .One, index, 0)); }
[Test] public void LastIndexOfReturnsLastPositionWhenFoundOtherwiseNegativeOne() { var sut = new CopyOnWriteList <T>(Samples.Concat(Samples)); var size = SampleSize; Assert.That(sut.LastIndexOf(TestData <T> .M1), Is.EqualTo(-1)); Assert.That(sut.LastIndexOf(TestData <T> .Two), Is.EqualTo(size + 2)); Assert.That(sut.LastIndexOf(TestData <T> .MakeData(size - 1)), Is.EqualTo(size * 2 - 1)); }
public int LastIndexOfWithCountReturnsPositionWhenFoundOtherwiseNegativeOne(T item, int index, int count) { var sut = new CopyOnWriteList <T>(Samples.Concat(Samples)); return(sut.LastIndexOf(item, index, count)); }
[Test] public void LastIndexOfChokesOnBadCount() { var sut = new CopyOnWriteList <T>(Samples); Assert.Catch <ArgumentOutOfRangeException>(() => sut.LastIndexOf(TestData <T> .One, 0, -1)); }