Ejemplo n.º 1
0
        public void When_List_AddDistinctWithComparer_Then_ItemAdded()
        {
            var list = ImmutableList <object> .Empty;
            var item = new object();

            Transactional.AddDistinct(ref list, item, EqualityComparer <object> .Default);

            Assert.AreEqual(1, list.Count);
            Assert.IsTrue(list.Contains(item));
        }
Ejemplo n.º 2
0
        public void When_List_AddDistinct_Twice_Then_ItemAddedOnlyOnce()
        {
            var list = ImmutableList <object> .Empty;
            var item = new object();

            var result1 = Transactional.AddDistinct(ref list, item);
            var result2 = Transactional.AddDistinct(ref list, item);

            Assert.AreEqual(1, list.Count);
            Assert.IsTrue(list.Contains(item));
            Assert.AreSame(result1, result2);
        }