public void User_CanPeekItemWhichWillBeDeletedFirst() { QueueModel <int> queue = null; var peekItem = 0; "Given there is an initialized queue with 3 items: 1000, 500, -100" .x(() => { queue = new QueueModel <int>(); queue.Initialize(); // items queue.Enqueue(1000); queue.Enqueue(500); queue.Enqueue(-100); }); "When user requests peek operation" .x(() => { peekItem = queue.PeekHeadItem(); }); "Then received peek item should be equal to 1000" .x(() => { peekItem.Should().Be(1000); }); "And last peek status should be 'Ok'" .x(() => { var status = queue.LastPeekStatus(); status.Should().Be(OperationStatus.Ok); }); }
public void When_UserMakeFewOperationsQueueItemsMustBeReceived() { QueueModel <int> queue = null; "Given there is an initialized queue with 5 items: 1, 2, 3, 4, 5" .x(() => { queue = new QueueModel <int>(); queue.Initialize(); // items queue.Enqueue(1); queue.Enqueue(2); queue.Enqueue(3); queue.Enqueue(4); queue.Enqueue(5); }); "When user produce two deque operations" .x(() => { queue.Dequeue(); queue.Dequeue(); }); "Then queue should contain only 3 4 5 items" .x(() => { var items = queue.GetItems(); items.Should().BeEquivalentTo(new List <int>() { 3, 4, 5 }); }); }
public void User_CanNotPeekItemFromEmptyQueue() { QueueModel <string> queue = null; "Given there is an initialized queue with 0 items" .x(() => { queue = new QueueModel <string>(); queue.Initialize(); }); "When user requests peek operation" .x(() => { queue.PeekHeadItem(); }); "Then last peek status should be 'Error'" .x(() => { var status = queue.LastPeekStatus(); status.Should().Be(OperationStatus.Error); }); }
public void User_CanDequeueFromNotEmptyQueue() { QueueModel <string> queue = null; "Given there is an initialized queue with 3 items" .x(() => { queue = new QueueModel <string>(); queue.Initialize(); // items queue.Enqueue("Item new"); queue.Enqueue("Item new two"); queue.Enqueue("Item new three"); }); "When user requests dequeue operation" .x(() => { queue.Dequeue(); }); "Then count of such queue should be 2" .x(() => { var count = queue.Size(); count.Should().Be(2); }); "And last dequeue status should be 'Ok'" .x(() => { var status = queue.LastDequeueStatus(); status.Should().Be(OperationStatus.Ok); }); }
public void User_CanAddItemToInitializedQueue() { QueueModel <string> queue = null; "Given there is an initialized queue with 3 items" .x(() => { queue = new QueueModel <string>(); queue.Initialize(); // items queue.Enqueue("Item new"); queue.Enqueue("Item new two"); queue.Enqueue("Item new three"); }); "When user adds new item to queue" .x(() => { queue.Enqueue("Add item again"); }); "Then count of such queue should be 4" .x(() => { var count = queue.Size(); count.Should().Be(4); }); "And last enqueue status should be 'Ok'" .x(() => { var status = queue.LastEnqueueStatus(); status.Should().Be(OperationStatus.Ok); }); }