[Test] public void FindAllReturnsNewCopyOnWriteListWithMatchItems() { var sut = new CopyOnWriteList <T>(Samples); var size = SampleSize; var odd = new List <T>((size + 1) / 2); var even = new List <T>((size + 1) / 2); for (int i = 0; i < size; i++) { var item = TestData <T> .MakeData(i); if (i % 2 == 0) { even.Add(item); } else { odd.Add(item); } } Assert.That(sut.FindAll(i => false).Count, Is.EqualTo(0)); CollectionAssert.AreEqual(odd, sut.FindAll(odd.Contains)); CollectionAssert.AreEqual(even, sut.FindAll(even.Contains)); var all = sut.FindAll(i => true); CollectionAssert.AreEqual(sut, all); all[0] = TestData <T> .M1; Assert.That(sut[0], Is.Not.EqualTo(TestData <T> .M1)); }
[Test] public void FindAllChokesOnNullMatchCriteria() { var sut = new CopyOnWriteList <T>(); Assert.Catch <ArgumentNullException>(() => sut.FindAll(null)); }