Пример #1
0
        public void UncheckedLayeredStack()
        {
            //  Arrange
            var stack = new CheckedLayeredStack <string>();

            //  Act
            stack.Lock();
            //  Assert
            Assert.True(stack.IsEmpty());
            Assert.Equal(1, stack.LockCount());
            //  Act
            stack.Unlock();
            //  Assert
            Assert.True(stack.IsEmpty());
            Assert.Equal(0, stack.LockCount());
            //  Assert
            Assert.Throws <NutmegException>(() => stack.Unlock());
        }
Пример #2
0
        public void StartsEmpty_IsEmpty_Test()
        {
            //  Arrange
            var stack = new CheckedLayeredStack <string>();
            //  Act
            var isEmpty = stack.IsEmpty();

            //  Assert
            Assert.True(isEmpty);
        }
Пример #3
0
        public void StartsEmptyLocked_IsEmpty_Test()
        {
            //  Arrange
            var stack = new CheckedLayeredStack <string>();

            stack.Push("p");
            stack.Push("q");
            stack.Lock();
            //  Act
            var isEmpty = stack.IsEmpty();
            var k       = stack.LockCount();

            //  Assert
            Assert.True(isEmpty);
            Assert.Equal(1, k);
        }
Пример #4
0
        public void SimplePop_Pop_Test()
        {
            //  Arrange
            var stack = new CheckedLayeredStack <string>();

            stack.Push("a");
            stack.Push("b");
            //  Act
            var b = stack.Pop();
            var a = stack.Pop();

            //  Assert
            Assert.True(stack.IsEmpty());
            Assert.Equal(0, stack.Size());
            Assert.Equal("b", b);
            Assert.Equal("a", a);
        }