示例#1
0
        public void ShouldReturnItemsInRevertedOrderThanWasInserted()
        {
            var items = new List <int> {
                18, 5, -6, 36, 48
            };
            var expectedList = new List <int>(items);

            expectedList.Reverse();

            var cut = new ListBasedStackImplementation <int>(items.Capacity);


            items.ForEach(item => cut.Push(item));

            expectedList.ForEach(expectedItem => { Assert.AreEqual(expectedItem, cut.Pop()); });
        }
示例#2
0
        public void ShouldReturnDifferentSizeWhenPop()
        {
            var cut   = new ListBasedStackImplementation <int>(10);
            var items = new List <int> {
                18, 5, -6, 36, 48
            };

            items.ForEach(item => cut.Push(item));

            var size = cut.CurrentSize;

            do
            {
                cut.Pop();
                size--;
                Assert.AreEqual(size, cut.CurrentSize);
            }while (size > 0);
        }
示例#3
0
 public void ShouldThrowExceptionWhenPopOnEmptyStack()
 {
     var cut  = new ListBasedStackImplementation <int>(1);
     var item = cut.Pop();
 }