[Test] public void FindLastReturnsLastItemMatchCriteriaOtherwiseDefaultValue() { var sut = new CopyOnWriteList <T>(Samples); Assert.That(sut.FindLast(b => b.Equals(TestData <T> .M1)), Is.EqualTo(default(T))); var head = TestData <T> .Zero; Assert.That(sut.FindLast(b => b.Equals(head)), Is.EqualTo(head)); var tail = TestData <T> .MakeData(SampleSize - 1); Assert.That(sut.FindLast(b => b.Equals(tail)), Is.EqualTo(tail)); var half = TestData <T> .MakeData(SampleSize / 2); Assert.That(sut.FindLast(b => b.Equals(half)), Is.EqualTo(half)); if (!typeof(T).IsValueType) { var zero = TestData <T> .MakeData(0); sut[SampleSize / 2] = zero; Assert.That(sut.FindLast(b => b.Equals(zero)), Is.SameAs(zero)); } }
[Test] public void FindLastChokesOnNullMatchCriteria() { var sut = new CopyOnWriteList <T>(); Assert.Catch <ArgumentNullException>(() => sut.FindLast(null)); }