Пример #1
0
        public void ShouldThrowExceptionWhenPushOnExceededSize()
        {
            var cut = new ListBasedStackImplementation <int>(1);

            cut.Push(3);
            cut.Push(12);
        }
Пример #2
0
        public void ShouldReturnDifferentSizeWhenPush()
        {
            var cut   = new ListBasedStackImplementation <int>(10);
            var items = new List <int> {
                18, 5, -6, 36, 48
            };

            for (int i = 0; i < items.Count; i++)
            {
                cut.Push(items[i]);
                Assert.AreEqual(i + 1, cut.CurrentSize);
            }
        }
Пример #3
0
        public void ShouldReturnSameSizeWhenPeek()
        {
            var cut   = new ListBasedStackImplementation <int>(10);
            var items = new List <int> {
                18, 5, -6, 36, 48
            };

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

            foreach (var item in items)
            {
                Assert.AreEqual(items.Last(), cut.Peek());
                Assert.AreEqual(items.Count, cut.CurrentSize);
            }
        }
Пример #4
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()); });
        }
Пример #5
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);
        }
Пример #6
0
        public void ShouldReturnZeroWhenStackIsEmpty()
        {
            var cut = new ListBasedStackImplementation <int>(10);

            Assert.AreEqual(0, cut.CurrentSize);
        }
Пример #7
0
 public void ShouldThrowExceptionWhenPeekOnEmptyStack()
 {
     var cut  = new ListBasedStackImplementation <int>(1);
     var item = cut.Peek();
 }