Ejemplo n.º 1
0
        public void ImmutableLinkedList_ReadOnlyList_IndexException()
        {
            var list = ImmutableLinkedList.Create(5, 10, 15);

            Assert.Throws <ArgumentOutOfRangeException>(() => list[-1]);
            Assert.Throws <ArgumentOutOfRangeException>(() => list[3]);
        }
Ejemplo n.º 2
0
        public void ImmutableLinkedList_ReadOnlyList()
        {
            var list = ImmutableLinkedList.Create(5, 10, 15);

            Assert.Equal(15, list[0]);
            Assert.Equal(10, list[1]);
            Assert.Equal(5, list[2]);
        }
Ejemplo n.º 3
0
        public void ImmutableLinkedList_Contains()
        {
            var list = ImmutableLinkedList.Create(5, 10, 15);

            Assert.True(list.Contains(5));
            Assert.True(list.Contains(10));
            Assert.True(list.Contains(15));
            Assert.False(list.Contains(0));
        }
Ejemplo n.º 4
0
        public void ImmutableLinkedList_Create()
        {
            var list = ImmutableLinkedList.Create(5, 10, 15);

            var newList = new List <int>(list);

            Assert.Equal(3, newList.Count);
            Assert.Contains(5, newList);
            Assert.Contains(10, newList);
            Assert.Contains(15, newList);
        }
Ejemplo n.º 5
0
        public void ImmutableLinkedList_Visit_Start_End()
        {
            var list = ImmutableLinkedList.Create(5, 10, 15);

            var newList = new List <int>();

            list.Visit(i => newList.Add(i), startAtEnd: true);

            Assert.Equal(3, newList.Count);
            Assert.Equal(5, newList[0]);
            Assert.Equal(10, newList[1]);
            Assert.Equal(15, newList[2]);
        }
Ejemplo n.º 6
0
        public void ImmutableLinkedList_ThreadSafeEmpty()
        {
            var list = ImmutableLinkedList.Create(5, 10, 15);

            var newList = new List <int>(list);

            Assert.Equal(3, newList.Count);
            Assert.Contains(5, newList);
            Assert.Contains(10, newList);
            Assert.Contains(15, newList);

            ImmutableLinkedList.ThreadSafeEmpty(ref list);

            newList = new List <int>(list);

            Assert.Empty(newList);
        }
Ejemplo n.º 7
0
 public void ImmutableLinkedList_Create_Returns_Empty_For_Null()
 {
     Assert.Equal(ImmutableLinkedList <int> .Empty, ImmutableLinkedList.Create <int>(null));
     Assert.Equal(ImmutableLinkedList <int> .Empty, ImmutableLinkedList.Create(new int[0]));
 }