[Test] public void RemoveAllKeepListUnchangedWhenNoMatch() { var sut = new CopyOnWriteList <T>(Samples); Assert.That(sut.RemoveAll(r => false), Is.EqualTo(0)); CollectionAssert.AreEqual(Samples, sut); }
[Test] public void RemoveAllChokesOnNullMatchCriteria() { var sut = new CopyOnWriteList <T>(Samples); var e = Assert.Catch <ArgumentNullException>( () => sut.RemoveAll(null)); Assert.That(e.ParamName, Is.EqualTo("match")); }
[Test] public void RemoveAllRemovesElementMatchsCriteria() { var sut = new CopyOnWriteList <T>(Samples); IList <T> c = new List <T>(); for (int i = SampleSize - 1; i >= 0; i -= 2) { c.Add(TestData <T> .MakeData(i)); } Assert.That(sut.RemoveAll(c.Contains), Is.EqualTo(c.Count)); Assert.That(sut.Count, Is.EqualTo(SampleSize - c.Count)); c = sut; sut = new CopyOnWriteList <T>(Samples); Assert.That(sut.RemoveAll(c.Contains), Is.EqualTo(c.Count)); Assert.That(sut.Count, Is.EqualTo(SampleSize - c.Count)); }