public void FindIndexChokesOnBadIndex(Position position) { var index = PositionToIndex(position); var sut = new CopyOnWriteList <T>(Samples); Assert.Catch <ArgumentOutOfRangeException>(() => sut.FindIndex(index, i => true)); Assert.Catch <ArgumentOutOfRangeException>(() => sut.FindIndex(index, 0, i => true)); }
[Test] public void FindIndexChokesOnNullMatchCriteria() { var sut = new CopyOnWriteList <T>(Samples); Assert.Catch <ArgumentNullException>(() => sut.FindIndex(null)); Assert.Catch <ArgumentNullException>(() => sut.FindIndex(0, null)); Assert.Catch <ArgumentNullException>(() => sut.FindIndex(0, 0, null)); }
[Test] public void FindIndexReturnsLastPositionWhenFoundOtherwiseNegativeOne() { var sut = new CopyOnWriteList <T>(Samples.Concat(Samples)); var size = SampleSize; sut[size * 2 - 1] = TestData <T> .MakeData(size); Assert.That(sut.FindIndex(i => i.Equals(TestData <T> .M1)), Is.EqualTo(-1)); Assert.That(sut.FindIndex(i => i.Equals(TestData <T> .Zero)), Is.EqualTo(0)); Assert.That(sut.FindIndex(i => i.Equals(TestData <T> .Two)), Is.EqualTo(2)); Assert.That(sut.FindIndex(i => i.Equals(TestData <T> .MakeData(size))), Is.EqualTo(size * 2 - 1)); }
public int FindIndexWithCountReturnsPositionWhenFoundOtherwiseNegativeOne(T item, int index, int count) { var sut = new CopyOnWriteList <T>(Samples); return(sut.FindIndex(index, count, i => i.Equals(item))); }
[Test] public void FindIndexChokesOnBadCount() { var sut = new CopyOnWriteList <T>(Samples); Assert.Catch <ArgumentOutOfRangeException>(() => sut.FindIndex(0, -1, i => true)); }