Пример #1
0
        public void Writes_to_original_are_not_visible_to_clones()
        {
            var items = new CopyOnWriteList <string>();

            items.Add("test");
            Assert.Equal("test", items[0]);

            var clone  = items.Clone();
            var clone2 = items.Clone();

            Assert.True(items.HasSameBacking(clone));
            Assert.True(items.HasSameBacking(clone2));

            items[0] = "no";

            Assert.False(items.HasSameBacking(clone));
            Assert.False(items.HasSameBacking(clone2));
            Assert.True(clone.HasSameBacking(clone2));

            Assert.Equal("test", clone[0]);
            Assert.Equal("test", clone2[0]);
        }