Ejemplo n.º 1
0
        public void CheckIfAddBeforeWorksCorrectly()
        {
            var linkedList = new DataStructures.DoubleLinkedListCollection <int>();

            linkedList.Add(1);
            linkedList.Add(3);
            linkedList.AddBefore(linkedList.Find(3), 2);
            Assert.Equal(2, linkedList.Find(1).NextLink.Value);
        }
Ejemplo n.º 2
0
        public void CheckIfAddBeforeArgumentNullExceptionWorksCorrectly()
        {
            var linkedList = new DataStructures.DoubleLinkedListCollection <int>();

            linkedList.Add(1);
            linkedList.Add(2);
            linkedList.Add(3);
            Assert.Throws <ArgumentNullException>(() => linkedList.AddBefore(null, 2));
        }
Ejemplo n.º 3
0
        public void CheckIfAddBeforeExceptionReadOnlyWorksCorrectly()
        {
            var linkedList = new DataStructures.DoubleLinkedListCollection <int>();

            linkedList.Add(1);
            linkedList.Add(2);
            linkedList.Add(3);
            linkedList.MakeReadOnly();
            Assert.Throws <NotSupportedException>(() => linkedList.AddBefore(linkedList.Find(3), 2));
        }
Ejemplo n.º 4
0
        public void CheckIfAddBeforeInvalidOperationExceptionWorksCorrectly()
        {
            var linkedList = new DataStructures.DoubleLinkedListCollection <int>();

            linkedList.Add(1);
            linkedList.Add(2);
            linkedList.Add(3);
            var newLink = new DataStructures.DoubleLink <int>(5);

            Assert.Throws <InvalidOperationException>(() => linkedList.AddBefore(newLink, 2));
        }