Esempio n. 1
0
        public void Enumerate()
        {
            var sut = new OneWayList <int>(iarray);

            // Assert
            Assert.AreEqual(iarray, sut.ToArray());
        }
Esempio n. 2
0
        public void EnumerateOnEmptyList()
        {
            var sut = new OneWayList <int>();

            // Assert
            Assert.AreEqual(new int[] { }, sut.ToArray());
        }
Esempio n. 3
0
        public void FailOnDeleteInEmptyList()
        {
            var sut = new OneWayList <int>();

            // Assert
            Assert.Throws <InvalidOperationException>(() => sut.DeleteFirst());
            Assert.Throws <InvalidOperationException>(() => sut.DeleteLast());
        }
Esempio n. 4
0
        public void InsertLastInList()
        {
            var sut = new OneWayList <int>(iarray);

            sut.InsertLast(2);
            // Assert
            Assert.AreEqual(2, sut.Tail.Value);
            Assert.AreEqual(iarray.Length + 1, sut.Count);
        }
Esempio n. 5
0
        public void FailOnOperationsWithInvalidNode()
        {
            var invalidNode = new OneWayListNode <int>(new OneWayList <int>(), 12);
            var sut         = new OneWayList <int>(iarray);

            // Assert
            Assert.Throws <InvalidOperationException>(() => sut.Delete(invalidNode));
            Assert.Throws <InvalidOperationException>(() => sut.InsertAfter(invalidNode, 12));
        }
Esempio n. 6
0
        public void DeleteLastInList()
        {
            var sut  = new OneWayList <int>(iarray);
            var last = iarray[iarray.Length - 1];

            sut.DeleteLast();
            // Assert
            Assert.AreNotEqual(last, sut.Tail.Value);
            Assert.AreEqual(iarray.Length - 1, sut.Count);
        }
Esempio n. 7
0
        public void DeleteFirstInList()
        {
            var sut   = new OneWayList <int>(iarray);
            var first = iarray[0];

            sut.DeleteFirst();
            // Assert
            Assert.AreNotEqual(first, sut.Head.Value);
            Assert.AreEqual(iarray.Length - 1, sut.Count);
        }
Esempio n. 8
0
        public void InsertLastInEmptyList()
        {
            var sut = new OneWayList <int>();

            sut.InsertLast(1);
            // Assert
            Assert.AreEqual(1, sut.Head.Value);
            Assert.AreEqual(1, sut.Count);
            Assert.AreEqual(sut.Head, sut.Tail);
        }
Esempio n. 9
0
        public void DeleteInMiddle()
        {
            int[] input     = new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
            int[] expOutput = new int[] { 1, 2, 3, 4, 6, 7, 8, 9, 10 };

            var sut = new OneWayList <int>(input);

            int index   = 5;
            var remNode = sut.Head;

            while (--index > 0)
            {
                remNode = remNode.Next;
            }


            sut.Delete(remNode);
            // Assert
            Assert.AreEqual(expOutput, sut.ToArray());
            Assert.AreEqual(expOutput.Count(), sut.Count);
        }
 public WeakClientSponsor(TimeSpan renewalTime)
 {
     this.LeaseObjectList = new OneWayList<KeyValuePair<ILease, WeakReference>>();
     this.RenewalTime = renewalTime;
 }