[Test] public void AddRangeIfAbsentAddOnlyThoseNotExist()
        {
            var sut = new CopyOnWriteList <T>(Samples);
            var c   = new[]
            {
                TestData <T> .M1,
                TestData <T> .M2,
                TestData <T> .One,           // Will no add.
            };

            Assert.That(sut.AddRangeAbsent(c), Is.EqualTo(2));
            Assert.That(sut.Count, Is.EqualTo(SampleSize + 2));
            Assert.IsTrue(sut.Contains(TestData <T> .M1));
            Assert.IsTrue(sut.Contains(TestData <T> .M2));
        }
        [Test] public void AddIfAbsentDoesAddWhenNotExist()
        {
            var sut = new CopyOnWriteList <T>(Samples);

            sut.AddIfAbsent(TestData <T> .M1);
            Assert.IsTrue(sut.Contains(TestData <T> .M1));
        }
 public void CopyOnWriteList_Should_Allow_Parallel_Calls_To_Add()
 {
     var actions = new List<Action>();
     var list = new CopyOnWriteList<int>();
     for (var i = 0; i < 100; i++)
     {
         var item = i;
         actions.Add(() =>
         {
             list.Add(item);
         });
     }
     TestHelper.ParallelInvoke(actions);
     Assert.AreEqual(100, list.Count);
     for (var i = 0; i < 100; i++)
     {
         Assert.True(list.Contains(i));
     }
     var counter = 0;
     CollectionAssert.AreEquivalent(Enumerable.Repeat(0, 100).Select(_ => counter++), list);
 }