public void FindLastIndexChokesOnBadIndex(Position position) { var index = PositionToIndex(position); var sut = new CopyOnWriteList <T>(Samples); Assert.Catch <ArgumentOutOfRangeException>(() => sut.FindLastIndex(index, i => true)); Assert.Catch <ArgumentOutOfRangeException>(() => sut.FindLastIndex(index, 0, i => true)); }
[Test] public void FindLastIndexChokesOnNullMatchCriteria() { var sut = new CopyOnWriteList <T>(Samples); Assert.Catch <ArgumentNullException>(() => sut.FindLastIndex(null)); Assert.Catch <ArgumentNullException>(() => sut.FindLastIndex(0, null)); Assert.Catch <ArgumentNullException>(() => sut.FindLastIndex(0, 0, null)); }
[Test] public void FindLastIndexReturnsLastPositionWhenFoundOtherwiseNegativeOne() { var sut = new CopyOnWriteList <T>(Samples.Concat(Samples)); var size = SampleSize; Assert.That(sut.FindLastIndex(i => i.Equals(TestData <T> .M1)), Is.EqualTo(-1)); Assert.That(sut.FindLastIndex(i => i.Equals(TestData <T> .Two)), Is.EqualTo(size + 2)); Assert.That(sut.FindLastIndex(i => i.Equals(TestData <T> .MakeData(size - 1))), Is.EqualTo(size * 2 - 1)); }
public int FindLastIndexWithCountReturnsPositionWhenFoundOtherwiseNegativeOne(T item, int index, int count) { var sut = new CopyOnWriteList <T>(Samples.Concat(Samples)); return(sut.FindLastIndex(index, count, i => i.Equals(item))); }
[Test] public void FindLastIndexChokesOnBadCount() { var sut = new CopyOnWriteList <T>(Samples); Assert.Catch <ArgumentOutOfRangeException>(() => sut.FindLastIndex(0, -1, i => true)); }