public void Should_Check_Head_Tail_Floating() { //arrange var queue = new MyArrayQueue <int>(); //act queue.Enqueue(1); queue.Enqueue(2); queue.Enqueue(3); queue.Enqueue(4); queue.Dequeue(); queue.Enqueue(5); var first = queue.Dequeue(); var second = queue.Dequeue(); var third = queue.Dequeue(); var fourth = queue.Dequeue(); //assert queue.Capacity.ShouldBeEquivalentTo(4); queue.Count.ShouldBeEquivalentTo(0); first.ShouldBeEquivalentTo(2); second.ShouldBeEquivalentTo(3); third.ShouldBeEquivalentTo(4); fourth.ShouldBeEquivalentTo(5); }
public void EnqueueDequeueTest() { MyQueue <int> Queue = new MyArrayQueue <int>(); Queue.Enqueue(85); Queue.Enqueue(48); Assert.AreEqual(Queue.Dequeue(), 85); Assert.AreEqual(Queue.Dequeue(), 48); }
public void Should_Check_Tail_Floating() { //arrange var queue = new MyArrayQueue <int>(1); //act queue.Enqueue(1); queue.Dequeue(); queue.Enqueue(2); var result = queue.Dequeue(); //assert result.ShouldBeEquivalentTo(2); queue.Count.ShouldBeEquivalentTo(0); queue.Capacity.ShouldBeEquivalentTo(1); }
public void Should_Check_Floating_Overflow_Multiple() { //arrange var queue = new MyArrayQueue <int>(1); //act queue.Enqueue(1); queue.Dequeue(); queue.Enqueue(2); queue.Enqueue(3); queue.Dequeue(); queue.Enqueue(4); queue.Enqueue(5); queue.Enqueue(6); queue.Enqueue(7); queue.Dequeue(); //assert queue.Capacity.ShouldBeEquivalentTo(8); queue.Count.ShouldBeEquivalentTo(4); queue.Dequeue().ShouldBeEquivalentTo(4); queue.Dequeue().ShouldBeEquivalentTo(5); queue.Dequeue().ShouldBeEquivalentTo(6); queue.Dequeue().ShouldBeEquivalentTo(7); }
public void Should_Dequeue_Throw_If_Is_Empty() { //arrange var queue = new MyArrayQueue <int>(); //act Action act = () => queue.Dequeue(); //assert act.ShouldThrow <InvalidOperationException>(); }
public void DequeueFromEmptyQueueTest() { MyQueue <int> Queue = new MyArrayQueue <int>(); try { Queue.Dequeue(); } catch (InvalidOperationException e) { StringAssert.Contains(e.Message, "Очередь пуста."); } }
public void Should_Check_Is_Empty_True() { //arrange var queue = new MyArrayQueue <int>(1); queue.Enqueue(1); queue.Dequeue(); //act var result = queue.IsEmpty(); //assert result.ShouldBeEquivalentTo(true); }
public void Should_Peek() { //arrange var queue = new MyArrayQueue <int>(); queue.Enqueue(1); queue.Enqueue(2); queue.Enqueue(3); queue.Enqueue(4); queue.Enqueue(5); //act var result = queue.Peek(); //assert result.ShouldBeEquivalentTo(1); queue.Capacity.ShouldBeEquivalentTo(8); queue.Count.ShouldBeEquivalentTo(5); queue.Dequeue().ShouldBeEquivalentTo(1); queue.Dequeue().ShouldBeEquivalentTo(2); queue.Dequeue().ShouldBeEquivalentTo(3); queue.Dequeue().ShouldBeEquivalentTo(4); queue.Dequeue().ShouldBeEquivalentTo(5); }
public void Should_Dequeue_Length_One() { //arrange var queue = new MyArrayQueue <int>(new List <int>() { 1 }); //act var result = queue.Dequeue(); //assert result.ShouldBeEquivalentTo(1); queue.Capacity.ShouldBeEquivalentTo(1); queue.Count.ShouldBeEquivalentTo(0); }
public void DequeueFromEmptyQueueTest() { MyQueue<int> Queue = new MyArrayQueue<int>(); try { Queue.Dequeue(); } catch (InvalidOperationException e) { StringAssert.Contains(e.Message, "Очередь пуста."); } }
public void EnqueueDequeueTest() { MyQueue<int> Queue = new MyArrayQueue<int>(); Queue.Enqueue(85); Queue.Enqueue(48); Assert.AreEqual(Queue.Dequeue(), 85); Assert.AreEqual(Queue.Dequeue(), 48); }