Example #1
0
        public void CanNotPeekWhenNoItemsInStack()
        {
            // Arrange
            var sut      = new QueueFromStacks <int>();
            var expected = false;

            // Act
            var actual = sut.CanPeek();

            // Assert
            Assert.AreEqual(expected, actual);
        }
Example #2
0
        public void OrderOfElementsMaintained()
        {
            // Arrange
            var sut = new QueueFromStacks <int>();

            // Act
            sut.Add(1);
            sut.Add(2);
            sut.Add(3);

            // Assert
            for (var expected = 1; expected <= 3; expected++)
            {
                var actual = sut.Remove();
                Assert.AreEqual(expected, actual);
            }
        }
Example #3
0
        public void RemoveReturnsFirstEntered()
        {
            // Arrange
            var sut      = new QueueFromStacks <int>();
            var expected = 1;

            sut.Add(expected);
            sut.Add(2);
            sut.Add(3);
            var expectedCount = sut.Count - 1;

            // Act
            var actual = sut.Remove();

            // Assert
            Assert.AreEqual(expected, actual);
            Assert.AreEqual(expectedCount, sut.Count);
        }
Example #4
0
        public void PeekReturnsFirstEnteredWithoutPopping()
        {
            // Arrange
            var sut      = new QueueFromStacks <int>();
            var expected = 1;

            sut.Add(expected);
            sut.Add(2);
            sut.Add(3);
            var expectedCount = sut.Count;

            // Act
            var actual = sut.Peek();

            // Assert
            Assert.AreEqual(expected, actual);
            Assert.AreEqual(expectedCount, sut.Count);
        }