コード例 #1
0
        public void PushShouldAddTheItemToFirstPlace()
        {
            WorkItemWaiterEntryStack stack      = new WorkItemWaiterEntryStack();
            IWorkItemWaiterEntry     firstEntry = Substitute.For <IWorkItemWaiterEntry>();
            IWorkItemWaiterEntry     lastEntry  = Substitute.For <IWorkItemWaiterEntry>();

            stack.Push(firstEntry);

            Assert.AreEqual(1, stack.Count);
            Assert.AreEqual(firstEntry, stack.Peek());

            stack.Push(lastEntry);

            Assert.AreEqual(lastEntry, stack.Peek());
            Assert.AreEqual(2, stack.Count);
        }
コード例 #2
0
        public void PeekShouldReturnLastAddedItemAndShouldNotRemoveItemWhenStackHasMoreThanOneItems()
        {
            WorkItemWaiterEntryStack stack      = new WorkItemWaiterEntryStack();
            IWorkItemWaiterEntry     firstEntry = Substitute.For <IWorkItemWaiterEntry>();
            IWorkItemWaiterEntry     lastEntry  = Substitute.For <IWorkItemWaiterEntry>();

            stack.Push(firstEntry);
            stack.Push(lastEntry);

            Assert.AreEqual(2, stack.Count);

            Assert.AreEqual(lastEntry, stack.Peek());
            Assert.AreEqual(2, stack.Count);

            Assert.AreEqual(lastEntry, stack.Peek());
            Assert.AreEqual(2, stack.Count);
        }
コード例 #3
0
        public void PopShouldReturnLastAddedItemAndDecrementCountWhenStackHasMoreThanOneItems()
        {
            WorkItemWaiterEntryStack stack = new WorkItemWaiterEntryStack();
            IWorkItemWaiterEntry firstEntry = Substitute.For<IWorkItemWaiterEntry>();
            IWorkItemWaiterEntry lastEntry = Substitute.For<IWorkItemWaiterEntry>();

            stack.Push(firstEntry);
            stack.Push(lastEntry);

            Assert.AreEqual(2, stack.Count);

            Assert.AreEqual(lastEntry, stack.Pop());
            Assert.AreEqual(1, stack.Count);

            Assert.AreEqual(firstEntry, stack.Pop());
            Assert.AreEqual(0, stack.Count);

            Assert.AreEqual(null, stack.Pop());
            Assert.AreEqual(0, stack.Count);
        }
コード例 #4
0
        public void PopShouldReturnLastAddedItemAndDecrementCountWhenStackHasMoreThanOneItems()
        {
            WorkItemWaiterEntryStack stack      = new WorkItemWaiterEntryStack();
            IWorkItemWaiterEntry     firstEntry = Substitute.For <IWorkItemWaiterEntry>();
            IWorkItemWaiterEntry     lastEntry  = Substitute.For <IWorkItemWaiterEntry>();

            stack.Push(firstEntry);
            stack.Push(lastEntry);

            Assert.AreEqual(2, stack.Count);

            Assert.AreEqual(lastEntry, stack.Pop());
            Assert.AreEqual(1, stack.Count);

            Assert.AreEqual(firstEntry, stack.Pop());
            Assert.AreEqual(0, stack.Count);

            Assert.AreEqual(null, stack.Pop());
            Assert.AreEqual(0, stack.Count);
        }
コード例 #5
0
        public void RemoveShouldRemoveItemFromStack()
        {
            WorkItemWaiterEntryStack stack      = new WorkItemWaiterEntryStack();
            IWorkItemWaiterEntry     firstEntry = Substitute.For <IWorkItemWaiterEntry>();
            IWorkItemWaiterEntry     lastEntry  = Substitute.For <IWorkItemWaiterEntry>();

            stack.Push(firstEntry);
            stack.Push(lastEntry);

            Assert.AreEqual(2, stack.Count);

            Assert.AreEqual(lastEntry, stack.Peek());
            Assert.AreEqual(true, stack.Remove(lastEntry));
            Assert.AreEqual(firstEntry, stack.Peek());

            Assert.AreEqual(1, stack.Count);

            Assert.AreEqual(true, stack.Remove(firstEntry));
            Assert.AreEqual(0, stack.Count);
        }
コード例 #6
0
        public void PeekShouldReturnTheOnlyItemAndShouldNotRemovwItemWhenStackHasOneItems()
        {
            WorkItemWaiterEntryStack stack = new WorkItemWaiterEntryStack();
            IWorkItemWaiterEntry entry = Substitute.For<IWorkItemWaiterEntry>();
            stack.Push(entry);

            Assert.AreEqual(entry, stack.Peek());
            Assert.AreEqual(1, stack.Count);

            Assert.AreEqual(entry, stack.Peek());
            Assert.AreEqual(1, stack.Count);
        }
コード例 #7
0
        public void PopShouldReturnTheOnlyItemAndSetCountToZeroWhenStackHasOneItems()
        {
            WorkItemWaiterEntryStack stack = new WorkItemWaiterEntryStack();
            IWorkItemWaiterEntry entry = Substitute.For<IWorkItemWaiterEntry>();
            stack.Push(entry);

            Assert.AreEqual(entry, stack.Pop());
            Assert.AreEqual(0, stack.Count);

            Assert.AreEqual(null, stack.Pop());
            Assert.AreEqual(0, stack.Count);
        }
コード例 #8
0
        public void PeekShouldReturnTheOnlyItemAndShouldNotRemovwItemWhenStackHasOneItems()
        {
            WorkItemWaiterEntryStack stack = new WorkItemWaiterEntryStack();
            IWorkItemWaiterEntry     entry = Substitute.For <IWorkItemWaiterEntry>();

            stack.Push(entry);

            Assert.AreEqual(entry, stack.Peek());
            Assert.AreEqual(1, stack.Count);

            Assert.AreEqual(entry, stack.Peek());
            Assert.AreEqual(1, stack.Count);
        }
コード例 #9
0
        public void PopShouldReturnTheOnlyItemAndSetCountToZeroWhenStackHasOneItems()
        {
            WorkItemWaiterEntryStack stack = new WorkItemWaiterEntryStack();
            IWorkItemWaiterEntry     entry = Substitute.For <IWorkItemWaiterEntry>();

            stack.Push(entry);

            Assert.AreEqual(entry, stack.Pop());
            Assert.AreEqual(0, stack.Count);

            Assert.AreEqual(null, stack.Pop());
            Assert.AreEqual(0, stack.Count);
        }
コード例 #10
0
        public void RemoveShouldReturnFalseIfTheSpecifiedItemIsNotFoundInTheStack()
        {
            WorkItemWaiterEntryStack stack      = new WorkItemWaiterEntryStack();
            IWorkItemWaiterEntry     firstEntry = Substitute.For <IWorkItemWaiterEntry>();
            IWorkItemWaiterEntry     lastEntry  = Substitute.For <IWorkItemWaiterEntry>();

            Assert.AreEqual(false, stack.Remove(firstEntry));

            stack.Push(firstEntry);

            Assert.AreEqual(1, stack.Count);

            Assert.AreEqual(false, stack.Remove(lastEntry));
        }
コード例 #11
0
        public void PeekShouldReturnLastAddedItemAndShouldNotRemoveItemWhenStackHasMoreThanOneItems()
        {
            WorkItemWaiterEntryStack stack = new WorkItemWaiterEntryStack();
            IWorkItemWaiterEntry firstEntry = Substitute.For<IWorkItemWaiterEntry>();
            IWorkItemWaiterEntry lastEntry = Substitute.For<IWorkItemWaiterEntry>();

            stack.Push(firstEntry);
            stack.Push(lastEntry);

            Assert.AreEqual(2, stack.Count);

            Assert.AreEqual(lastEntry, stack.Peek());
            Assert.AreEqual(2, stack.Count);

            Assert.AreEqual(lastEntry, stack.Peek());
            Assert.AreEqual(2, stack.Count);
        }
コード例 #12
0
        public void RemoveShouldReturnFalseIfTheSpecifiedItemIsNotFoundInTheStack()
        {
            WorkItemWaiterEntryStack stack = new WorkItemWaiterEntryStack();
            IWorkItemWaiterEntry firstEntry = Substitute.For<IWorkItemWaiterEntry>();
            IWorkItemWaiterEntry lastEntry = Substitute.For<IWorkItemWaiterEntry>();

            Assert.AreEqual(false, stack.Remove(firstEntry));

            stack.Push(firstEntry);

            Assert.AreEqual(1, stack.Count);

            Assert.AreEqual(false, stack.Remove(lastEntry));
        }
コード例 #13
0
        public void RemoveShouldRemoveItemFromStack()
        {
            WorkItemWaiterEntryStack stack = new WorkItemWaiterEntryStack();
            IWorkItemWaiterEntry firstEntry = Substitute.For<IWorkItemWaiterEntry>();
            IWorkItemWaiterEntry lastEntry = Substitute.For<IWorkItemWaiterEntry>();

            stack.Push(firstEntry);
            stack.Push(lastEntry);

            Assert.AreEqual(2, stack.Count);

            Assert.AreEqual(lastEntry, stack.Peek());
            Assert.AreEqual(true, stack.Remove(lastEntry));
            Assert.AreEqual(firstEntry, stack.Peek());

            Assert.AreEqual(1, stack.Count);

            Assert.AreEqual(true, stack.Remove(firstEntry));
            Assert.AreEqual(0, stack.Count);
        }
コード例 #14
0
        public void PushShouldThrowExceptionWhenItemIsEmpty()
        {
            WorkItemWaiterEntryStack stack = new WorkItemWaiterEntryStack();

            Assert.Throws<ArgumentNullException>(() => stack.Push(null));
        }
コード例 #15
0
        public void PushShouldAddTheItemToFirstPlace()
        {
            WorkItemWaiterEntryStack stack = new WorkItemWaiterEntryStack();
            IWorkItemWaiterEntry firstEntry = Substitute.For<IWorkItemWaiterEntry>();
            IWorkItemWaiterEntry lastEntry = Substitute.For<IWorkItemWaiterEntry>();

            stack.Push(firstEntry);

            Assert.AreEqual(1, stack.Count);
            Assert.AreEqual(firstEntry, stack.Peek());

            stack.Push(lastEntry);

            Assert.AreEqual(lastEntry, stack.Peek());
            Assert.AreEqual(2, stack.Count);
        }
コード例 #16
0
        public void PushShouldThrowExceptionWhenItemIsEmpty()
        {
            WorkItemWaiterEntryStack stack = new WorkItemWaiterEntryStack();

            Assert.Throws <ArgumentNullException>(() => stack.Push(null));
        }