public void TestEnumerator_Enqueue20ElementsDequeue10ElementsEnqueue10Elements_Capacity20() { CustomQueue <int> queue = new CustomQueue <int>(); for (int i = 0; i < 20; i++) { queue.Enqueue(i); } for (int i = 0; i < 9; i++) { queue.Dequeue(); } for (int i = 0; i < 8; i++) { queue.Enqueue(i); } bool isRightOrder = true; int expectedValue = 9; foreach (var item in queue) { isRightOrder &= item == expectedValue % 20; expectedValue++; } Assert.IsTrue(isRightOrder); }
static void Main(string[] args) { CustomQueue<object> queue = new CustomQueue<object>(); queue.Enqueue("My name is Nataly"); queue.Enqueue("Something else"); queue.Enqueue(312); CustomQueue<object> queue2 = queue.Clone(); CustomQueue<object> queue3 = queue; queue.Enqueue(new List<int>()); queue.Enqueue(new DateTime()); foreach (var variable in queue) { Console.WriteLine(variable); } Console.WriteLine('\n'); foreach (var variable in queue2) { Console.WriteLine(variable); } Console.WriteLine('\n'); foreach (var variable in queue3) { Console.WriteLine(variable); } Console.WriteLine('\n'); Console.ReadLine(); }
public static void Run() { CustomQueue<int> queue = new CustomQueue<int>(); for (int i = 0; i < 24; i++) queue.Enqueue(i + 1); for (int i = 0; i < 24; i++) queue.Dequeue(); // queue.Dequeue(); // queue.Dequeue(); queue.Enqueue(7); queue.Enqueue(8); // queue.Dequeue(); // queue.Dequeue(); queue.Enqueue(9); queue.Enqueue(10); queue.Dequeue(); Console.WriteLine("For:"); for (int i = 0; i < queue.Count; i++) Console.WriteLine(queue[i]); Console.WriteLine("Peek: {0}", queue.Peek()); Console.WriteLine("Peek: {0}", queue.Peek()); Console.WriteLine("Peek: {0}", queue.Peek()); Console.WriteLine("Foreach:"); foreach (int i in queue) Console.WriteLine(i); }
public void TestBefore() { queue = new CustomQueue <string>(); queue.Enqueue("one"); queue.Enqueue("two"); queue.Enqueue("last"); }
static void Queue() { CustomQueue cq = new CustomQueue(20); cq.Enqueue(10); cq.Enqueue(20); cq.Enqueue(30); Console.WriteLine(cq.Count); var tmp = cq.GetItem(); for (int i = 0; i < tmp.Length; i++) { Console.WriteLine("Item -> " + tmp[i]); } cq.Dequeue(); Console.WriteLine("After Dequeuing : "); tmp = cq.GetItem(); for (int i = 0; i < tmp.Length; i++) { Console.WriteLine("Item -> " + tmp[i]); } cq.Enqueue(40); Console.WriteLine("After adding 40 : "); tmp = cq.GetItem(); for (int i = 0; i < tmp.Length; i++) { Console.WriteLine("Item -> " + tmp[i]); } }
public void Setup() { queueInt = new CustomQueue<int> (); queueInt.Enqueue (1); queueInt.Enqueue (3); queueInt.Enqueue (5); }
public void TestCircularBuffer_Enqueue20ElementsDequeue10ElementsEnqueue10Elements_Capacity20() { CustomQueue <int> queue = new CustomQueue <int>(); for (int i = 0; i < 20; i++) { queue.Enqueue(i); } System.Diagnostics.Debug.WriteLine("\n\n\tCount = {0}\n\n", queue.Count); for (int i = 0; i < 10; i++) { queue.Dequeue(); } System.Diagnostics.Debug.WriteLine("\n\n\tCount = {0}\n\n", queue.Count); for (int i = 0; i < 10; i++) { queue.Enqueue(i); } System.Diagnostics.Debug.WriteLine("\n\n\tCount = {0}\n\n", queue.Count); bool isRightOrder = true; for (int i = 10; i < 30; i++) { isRightOrder &= queue.Dequeue() == i % 20; } Assert.IsTrue(isRightOrder && queue.Capacity == 20); }
public void TestCircularBuffer_Enqueue20ElementsDequeue10ElementsEnqueue10Elements_Capacity20() { CustomQueue<int> queue = new CustomQueue<int>(); for (int i = 0; i < 20; i++) { queue.Enqueue(i); } System.Diagnostics.Debug.WriteLine("\n\n\tCount = {0}\n\n", queue.Count); for (int i = 0; i < 10; i++) { queue.Dequeue(); } System.Diagnostics.Debug.WriteLine("\n\n\tCount = {0}\n\n", queue.Count); for (int i = 0; i < 10; i++) { queue.Enqueue(i); } System.Diagnostics.Debug.WriteLine("\n\n\tCount = {0}\n\n", queue.Count); bool isRightOrder = true; for (int i = 10; i < 30; i++) { isRightOrder &= queue.Dequeue() == i % 20; } Assert.IsTrue(isRightOrder && queue.Capacity == 20); }
public void Enqueue_NormalConditions_Test() { CustomQueue <string> testQueue = new CustomQueue <string>(); testQueue.Enqueue("Test"); testQueue.Enqueue("Test2"); Assert.That(testQueue.Peek(), Is.EqualTo("Test")); }
public void CustomQueue_UsualDate_EnqueueTest() { CustomQueue<int> queue = new CustomQueue<int>(1); queue.Enqueue(1); queue.Enqueue(2); Assert.AreEqual(2, queue.Count); }
public void Peek_FromThreeIntQueue_ReturnsFirstOne() { CustomQueue<int> queue = new CustomQueue<int>(); queue.Enqueue(5); queue.Enqueue(6); queue.Enqueue(11); Assert.AreEqual(5, queue.Peek()); }
public void QueueAddElementsCorrectly() { var queue = new CustomQueue <int>(); queue.Enqueue(1); queue.Enqueue(3); queue.Enqueue(19); Assert.Equal(3, queue.Count); }
public void CustomQueue_Exeption_DequeueTest() { CustomQueue<int> queue = new CustomQueue<int>(1); queue.Enqueue(1); queue.Enqueue(2); queue.Dequeue(); queue.Dequeue(); queue.Dequeue(); }
static void Main(string[] args) { WriteLine("Start Queue test"); CustomQueue <int> queue = new CustomQueue <int>(new List <int> { 0, 1, 2, 4, 5, -5, -8, 95 }); WriteLine("\nTest foreach"); foreach (var i in queue) { Write($"{i} .. "); } queue.Enqueue(57); queue.Enqueue(-57); queue.Enqueue(0); WriteLine("\nTest Enqueue /57, -57, 0/"); foreach (var i in queue) { Write($"{i} .. "); } WriteLine("\nTest Error when enumerate and modify"); try { foreach (var i in queue) { Write($"{i} .. "); WriteLine($"Try to dequeue: {queue.Dequeue()}"); } } catch (InvalidOperationException ex) { WriteLine(ex); } WriteLine("\nTest Dequeue 6 elements"); WriteLine($"Dequeue: {queue.Dequeue()}"); WriteLine($"Dequeue: {queue.Dequeue()}"); WriteLine($"Dequeue: {queue.Dequeue()}"); WriteLine($"Dequeue: {queue.Dequeue()}"); WriteLine($"Dequeue: {queue.Dequeue()}"); WriteLine($"Dequeue: {queue.Dequeue()}"); WriteLine("\nWrite after dequeue"); foreach (var i in queue) { Write($"{i} .. "); } WriteLine("\nCheck Peek"); WriteLine($"Peek: {queue.Peek()}"); WriteLine("\nTest Clear"); queue.Clear(); WriteLine($"Count: {queue.Count}"); ReadLine(); }
public void CustomQueue_Peek_Test() { CustomQueue<int> queue = new CustomQueue<int>(1); queue.Enqueue(1); queue.Enqueue(2); var item = queue.Peek(); Assert.AreEqual(1, item); }
static void Main(string[] args) { var queue = new CustomQueue <int>(); queue.Enqueue(5); queue.Enqueue(200); Console.WriteLine(queue.Count); Console.ReadKey(); }
public void DequeueAndEnqueue_FilledWithEnqueueDequeueOneElement_ReturnsExpectedQueue() { var queue = new CustomQueue<int>(new[] { 1, 2, 3, 4, 5 }); var result = new CustomQueue<int>(); result.Enqueue(2); result.Enqueue(3); result.Enqueue(4); result.Enqueue(5); queue.Dequeue(); Assert.AreEqual(result, queue); }
public void GivenQueueWithFiveItemAndFirstItemIs84_WhenDequeue_ThenTheItemRemovedIsEqualTo84() { var queue = new CustomQueue<int>(); queue.Enqueue(84); queue.Enqueue(77); queue.Enqueue(99); queue.Enqueue(71); queue.Enqueue(18); var result = queue.Dequeue(); Assert.AreEqual(84, result); }
public void Enqueue_TwoClassElements() { var queue = new CustomQueue <Note>(); queue.Enqueue(new Note("PashaFast", "BSU", "Bla-bla", 1)); queue.Enqueue(new Note("JohnSkeet", "C#", "Bla-bla-bla", 2)); bool actual = queue.Contains(new Note("PashaFast", "BSU", "Bla-bla", 1)); Assert.AreEqual(true, actual); }
public void TestMethod1() { var queue = new CustomQueue<int>(); queue.Enqueue(1); Assert.AreEqual(queue.Dequeue(), 1); queue.Dequeue(); queue.Enqueue(1); Assert.AreEqual(queue.Dequeue(),1); queue.Dequeue(); }
public void CustomQueue_CopyTo_NullArray_Test() { var customQueue = new CustomQueue <int>(); customQueue.Enqueue(1); customQueue.Enqueue(2); customQueue.Enqueue(3); customQueue.Enqueue(4); Assert.Throws <ArgumentNullException>(() => customQueue.CopyTo(null, 2)); }
public void CustomQueue_Peek_Int_Test() { var customQueue = new CustomQueue <int>(); customQueue.Enqueue(1); customQueue.Enqueue(2); customQueue.Enqueue(3); customQueue.Enqueue(4); customQueue.Enqueue(5); Assert.AreEqual(customQueue.Peek(), 1); }
public void DequeueAndEnqueue_FilledWithEnqueueDequeueOneElement_ReturnsExpectedQueue() { var queue = new CustomQueue <int>(new[] { 1, 2, 3, 4, 5 }); var result = new CustomQueue <int>(); result.Enqueue(2); result.Enqueue(3); result.Enqueue(4); result.Enqueue(5); queue.Dequeue(); Assert.AreEqual(result, queue); }
public void CustomQueue_CopyTo_InvalidIndex_NotEnoughPlaceForInsert_Test() { var array = new[] { 7, 7, 7, 7, 7, 7, 7, 7 }; var customQueue = new CustomQueue <int>(); customQueue.Enqueue(1); customQueue.Enqueue(2); customQueue.Enqueue(3); customQueue.Enqueue(4); Assert.Throws <ArgumentException>(() => customQueue.CopyTo(array, 6)); }
static void Main(string[] args) { CustomQueue<int> queue = new CustomQueue<int>(); queue.Enqueue(12); queue.Enqueue(1); queue.Enqueue(1111); foreach(var a in queue) { Console.WriteLine($"{a}"); } Console.Read(); }
public void Enqueue_Test() { // ARRANGE var queue = new CustomQueue <int>(); // ACT queue.Enqueue(1); queue.Enqueue(2); // ASSERT Assert.AreEqual(2, queue.Count); }
public void CustomQueue_CopyTo_InvalidBigIndex_Test() { var array = new[] { 7, 7, 7, 7, 7, 7, 7, 7 }; var customQueue = new CustomQueue <int>(); customQueue.Enqueue(1); customQueue.Enqueue(2); customQueue.Enqueue(3); customQueue.Enqueue(4); Assert.Throws <InvalidOperationException>(() => customQueue.CopyTo(array, 20)); }
public void CustomQueue_CopyTo_NegativeIndex_Test() { var array = new[] { 7, 7, 7, 7, 7, 7, 7, 7 }; var customQueue = new CustomQueue <int>(); customQueue.Enqueue(1); customQueue.Enqueue(2); customQueue.Enqueue(3); customQueue.Enqueue(4); Assert.Throws <ArgumentOutOfRangeException>(() => customQueue.CopyTo(array, -2)); }
/* Task 13: * Implement the ADT queue as dynamic linked list. * Use generics (LinkedQueue<T>) to allow storing different data types in the queue. */ static void Main(string[] args) { var customQueue = new CustomQueue<int>(); customQueue.Enqueue(15); customQueue.Enqueue(25); customQueue.Enqueue(35); customQueue.Enqueue(45); Console.WriteLine("Custom Queue Count: {0}", customQueue.Count()); Console.WriteLine("Removed element {0}", customQueue.Dequeue()); Console.WriteLine("Custom Queue Count: {0}", customQueue.Count()); }
public void ShouldAddValuesToQueue() { //Arange var queue = new CustomQueue <int>(); int exceptedResult = 2; //Act queue.Enqueue(1); queue.Enqueue(1); //Assert Assert.AreEqual(exceptedResult, queue.Count); }
public void Enqueue_ThreeStructElements() { var queue = new CustomQueue <Point>(); queue.Enqueue(new Point(1, 2)); queue.Enqueue(new Point(2, 2)); queue.Enqueue(new Point(5, 2)); bool actual = queue.Contains(new Point(1, 2)); Assert.AreEqual(true, actual); }
static void Main() { var testQ = new CustomQueue<int>(); testQ.Enqueue(1); testQ.Enqueue(2); testQ.Enqueue(3); while (testQ.Count > 0) { Console.WriteLine(testQ.Dequeue()); } }
public void CustomQueue_Foreach_Test() { CustomQueue<int> queue = new CustomQueue<int>(1); queue.Enqueue(1); queue.Enqueue(2); int count = 0; foreach (var item in queue) { count++; } Assert.AreEqual(2, count); }
static void Main() { var testQ = new CustomQueue <int>(); testQ.Enqueue(1); testQ.Enqueue(2); testQ.Enqueue(3); while (testQ.Count > 0) { Console.WriteLine(testQ.Dequeue()); } }
static void Main(string[] args) { CustomQueue <int> queue = new CustomQueue <int>(); queue.Enqueue(12); queue.Enqueue(1); queue.Enqueue(1111); foreach (var a in queue) { Console.WriteLine($"{a}"); } Console.Read(); }
public void GivenQueueWithFiveItemAndFirstItemIs84_WhenDequeue_ThenTheItemRemovedIsEqualTo84() { var queue = new CustomQueue <int>(); queue.Enqueue(84); queue.Enqueue(77); queue.Enqueue(99); queue.Enqueue(71); queue.Enqueue(18); var result = queue.Dequeue(); Assert.AreEqual(84, result); }
public void Enqueue_ThreeIntElementsInQueueAndDequeue() { var stack = new CustomQueue <int>(); stack.Enqueue(1); stack.Enqueue(2); stack.Enqueue(3); stack.Dequeue(); bool actual = stack.Contains(1); Assert.AreEqual(false, actual); }
public void QueueRemoveSeveralElementsCorrectly() { var queue = new CustomQueue <int>(); queue.Enqueue(7); queue.Enqueue(18); queue.Enqueue(25); queue.Dequeue(); var lastElement = queue.Dequeue(); Assert.Equal(18, lastElement); Assert.Equal(1, queue.Count); }
static void Main() { CustomQueue<int> testQueue = new CustomQueue<int>(); testQueue.Enqueue(1); testQueue.Enqueue(2); testQueue.Enqueue(3); Console.WriteLine("Queue Lenght: {0}", testQueue.Count); Console.WriteLine("Dequeued Item: {0}", testQueue.Dequeue()); Console.WriteLine("Dequeued Item: {0}", testQueue.Dequeue()); Console.WriteLine("Peeking at Item: {0}", testQueue.Peek()); }
public void CustomQueue_Enqueue_Int_Test() { var customQueue = new CustomQueue <int>(); customQueue.Enqueue(1); customQueue.Enqueue(2); customQueue.Enqueue(3); customQueue.Enqueue(4); customQueue.Enqueue(5); Assert.AreEqual(customQueue.Capacity, 8); Assert.AreEqual(customQueue.Count, 5); }
static void Main(string[] args) { WriteLine("Start Queue test"); CustomQueue<int> queue = new CustomQueue<int>(new List<int> { 0, 1, 2, 4, 5, -5, -8, 95 }); WriteLine("\nTest foreach"); foreach(var i in queue) { Write($"{i} .. "); } queue.Enqueue(57); queue.Enqueue(-57); queue.Enqueue(0); WriteLine("\nTest Enqueue /57, -57, 0/"); foreach (var i in queue) { Write($"{i} .. "); } WriteLine("\nTest Error when enumerate and modify"); try { foreach(var i in queue) { Write($"{i} .. "); WriteLine($"Try to dequeue: {queue.Dequeue()}"); } } catch(InvalidOperationException ex) { WriteLine(ex); } WriteLine("\nTest Dequeue 6 elements"); WriteLine($"Dequeue: {queue.Dequeue()}"); WriteLine($"Dequeue: {queue.Dequeue()}"); WriteLine($"Dequeue: {queue.Dequeue()}"); WriteLine($"Dequeue: {queue.Dequeue()}"); WriteLine($"Dequeue: {queue.Dequeue()}"); WriteLine($"Dequeue: {queue.Dequeue()}"); WriteLine("\nWrite after dequeue"); foreach (var i in queue) { Write($"{i} .. "); } WriteLine("\nCheck Peek"); WriteLine($"Peek: {queue.Peek()}"); WriteLine("\nTest Clear"); queue.Clear(); WriteLine($"Count: {queue.Count}"); ReadLine(); }
public void ClearShouldClearAllData() { //Arange var queue = new CustomQueue <int>(); //Act queue.Enqueue(1); queue.Enqueue(2); queue.Enqueue(3); queue.Enqueue(4); queue.Clear(); //Assert Assert.AreEqual(0, queue.Count); }
static void Main() { Queue<int> abv = new Queue<int>(); //abv.Pe CustomQueue<int> customList = new CustomQueue<int>(); customList.Enqueue(3); customList.Enqueue(5); customList.Enqueue(1); Console.WriteLine(customList.Dequeue()); Console.WriteLine(customList.Dequeue()); customList.Enqueue(12); Console.WriteLine(customList.Dequeue()); Console.WriteLine(customList.Count); }
public void QueuePeekSeveralElementsWorkCorrectly() { var queue = new CustomQueue <int>(); queue.Enqueue(7); queue.Enqueue(9); queue.Enqueue(11); queue.Peek(); queue.Peek(); var lastElement = queue.Peek(); Assert.Equal(7, lastElement); Assert.Equal(3, queue.Count); }
public void PeekShouldReturnFirstItemOfTheQueue() { //Arange var queue = new CustomQueue <int>(); //Act queue.Enqueue(1); queue.Enqueue(2); queue.Enqueue(5); queue.Enqueue(4); queue.Enqueue(3); //Assert Assert.AreEqual(1, queue.Peek()); }
public void Method1() { CustomQueue cq = new CustomQueue(); cq.Enqueue(10); cq.Enqueue(20); cq.Enqueue(30); Assert.AreEqual(3, cq.Count, 0); var tmp = cq.GetItem(); Assert.AreEqual(3, tmp.Length); }
public void Enqueue_ThreeStringElementsInQueueAndDequeue() { var stack = new CustomQueue <String>(); stack.Enqueue("Natasha"); stack.Enqueue("Skeet"); stack.Enqueue("PashaFast"); stack.Dequeue(); string pashafast = "Skeet"; Assert.AreEqual(pashafast, stack.Peek()); }
public void EnqueueTestMethod() { var queue = new CustomQueue <int>(); queue.Enqueue(10); queue.Enqueue(20); queue.Enqueue(30); queue.Enqueue(40); queue.Enqueue(50); var expected = new[] { 10, 20, 30, 40, 50 }; var actual = queue.ToArray(); CollectionAssert.AreEqual(expected, actual); }
public void Enqueue_Int_AddsToQueue() { CustomQueue<int> queue = new CustomQueue<int>(); queue.Enqueue(5); Assert.AreEqual(5, queue.Peek()); }
public void TestMethodsEnqueuDequeuPeek(int[] expectedArray, int expectedPeek) { CustomQueue<int> customQueue = new CustomQueue<int>(); var customIter = customQueue.GetEnumerator(); Queue<int> queue = new Queue<int>(); customQueue.Enqueue(1); customQueue.Enqueue(2); customQueue.Enqueue(4); customQueue.Enqueue(8); customQueue.Enqueue(9); customQueue.Dequeue(); Assert.AreEqual(customQueue.Peek(), expectedPeek); int[] array = customQueue.ToArray(); CollectionAssert.AreEqual(expectedArray, array); }
public void testQueueAddAValue() { CustomQueue<Element> customQueue = new CustomQueue<Element>(); Element e = new Element(1, "A"); customQueue.Enqueue(e); Assert.AreEqual(e.getText(), customQueue.Dequeue().getText()); }
static void Main(string[] args) { CustomQueue<int> CQ = new CustomQueue<int>(); CQ.Enqueue(1); CQ.Enqueue(2); CQ.Enqueue(3); CQ.Enqueue(4); CQ.Enqueue(5); Console.WriteLine(CQ.Peek()); int first = CQ.Dequeue(); Console.WriteLine(CQ.Peek()); foreach (int i in CQ) Console.Write(i + " "); Console.WriteLine(); Console.WriteLine(CQ.Peek()); }
public void PeekElementFromQueueTest() { CustomQueue<int> myQueue = new CustomQueue<int>(); myQueue.Enqueue(new int[]{2, 12, 52, 82, 4, 2}); myQueue.Dequeue(); int actual = myQueue.Peek(); int expected = 12; Assert.AreEqual(expected, actual); }
static void Main(string[] args) { int[] mas1 = { 1, 2, 3, 4 }; int[] mas2 = { 5, 6, 7, 8 }; int[] mas3 = { 9, 0, 1, 2 }; int[] mas4 = { 0, 6, 7, 9 }; int[] mas5 = { 0, 6, 7, 9 }; CustomQueue<int[]> testQueue = new CustomQueue<int[]>(); testQueue.Enqueue(mas1); testQueue.Enqueue(mas2); testQueue.Enqueue(mas3); testQueue.Dequeue(); testQueue.Enqueue(mas4); foreach (var a in testQueue) { Console.WriteLine(string.Join(",", a)); } }
public static void Main() { CustomQueue<int> q = new CustomQueue<int>(); q.Enqueue(5); q.Enqueue(6); q.Enqueue(7); q.Enqueue(8); q.Enqueue(9); Console.WriteLine(q.Contains(9)); Console.WriteLine(q.Dequeue()); Console.WriteLine(q.Dequeue()); Console.WriteLine(q.Dequeue()); Console.WriteLine(q.Dequeue()); Console.WriteLine(q.Contains(6)); Console.WriteLine(q.Count); }
static void Main(string[] args) { CustomQueue<int> myQueue = new CustomQueue<int>(); myQueue.Enqueue(new int[]{2,5,12,53,24,1}); Console.WriteLine("First Call"); foreach (var i in myQueue) { Console.Write("{0}\t",i); } Console.ReadKey(true); }
public void CustomQueue_ContainsTrueTest() { CustomQueue<int> myQueue = new CustomQueue<int>(); for (int i = 0; i < 10; i++) { myQueue.Enqueue(i); } Assert.IsTrue(myQueue.Contains(3)); }
public void Enqueue_GivenSix_ReturnsSixWhenDequeuePreviousElements() { var queue = new CustomQueue<int>(new[] { 1, 2, 3, 4, 5 }); queue.Enqueue(6); for (int i = 0; i < 5; i++) { queue.Dequeue(); } var lastElement = queue.Peek(); Assert.AreEqual(6, lastElement); }
static void Main(string[] args) { CustomQueue<int> queue = new CustomQueue<int>(); for (int i = 0; i < 10; i++) queue.Enqueue(i * i); foreach (var item in queue) { System.Console.WriteLine(item); } System.Console.ReadLine(); }
static void Main(string[] args) { CustomQueue<int> q = new CustomQueue<int>(20); for (int i = 0; i<20; i++) { q.Enqueue(i); } for (int i = 0; i<10; i++) Console.WriteLine(q.Dequeue()); for (int i = 100; i < 110; i++) { q.Enqueue(i); } Console.WriteLine("Enqueued"); foreach (int a in q) { Console.WriteLine(a); } Console.WriteLine(q.Peek()); }