예제 #1
0
        public void FourElementsStackAddedFourElements_IsFull()
        {
            var stack = new MyStack_old <double>(4);

            stack.WriteElement(12);
            stack.WriteElement(15);
            stack.WriteElement(10);
            stack.WriteElement(11);

            Assert.IsTrue(stack.IsFull);
        }
예제 #2
0
        public void The_Output_Elemnet_Is_The_Top_Of_The_Stack()
        {
            //Arrange
            var stack = new MyStack_old <double>(10);

            //Act
            stack.WriteElement(1);
            stack.WriteElement(2);
            stack.WriteElement(3);
            stack.WriteElement(4);
            stack.WriteElement(5);

            //Assert
            Assert.AreEqual(5, stack.CheckElement());
        }
예제 #3
0
        public void Last_In_First_Out()
        {
            // Arrange
            var stack  = new MyStack_old <string>(4);
            var value1 = "3.3";
            var value2 = "6.5";
            var value3 = "9.4";
            var value4 = "6.6";

            //Act
            stack.WriteElement(value1);
            stack.WriteElement(value2);
            stack.WriteElement(value3);
            stack.WriteElement(value4);

            //Assert
            Assert.AreEqual(value4, stack.ReadElement());
            Assert.AreEqual(value3, stack.ReadElement());
            Assert.AreEqual(value2, stack.ReadElement());
            Assert.AreEqual(value1, stack.ReadElement());
            Assert.IsTrue(stack.IsEmpty);
        }