public void CustomQueue_Clear_Int_Test() { var customQueue = new CustomQueue <int>(); customQueue.Enqueue(1); customQueue.Enqueue(2); customQueue.Enqueue(3); customQueue.Enqueue(4); customQueue.Enqueue(5); customQueue.Enqueue(6); customQueue.Enqueue(7); customQueue.Enqueue(1); customQueue.Enqueue(2); customQueue.Enqueue(3); customQueue.Enqueue(4); customQueue.Enqueue(5); customQueue.Enqueue(6); customQueue.Enqueue(7); Assert.AreEqual(customQueue.Capacity, 16); Assert.AreEqual(customQueue.Count, 14); customQueue.Clear(); Assert.AreEqual(customQueue.Capacity, 8); Assert.AreEqual(customQueue.Count, 0); }
public void TestClear_EmptyQueue() { CustomQueue <int> queue = new CustomQueue <int>(); queue.Clear(); Assert.AreEqual(0, queue.Count); }
public object[] Queue_Clear_IsCorrect(object[] input) { CustomQueue <object> queue = new CustomQueue <object>(input); queue.Clear(); return(queue.ToArray()); }
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 TestCountAfterClear() { var queue = new CustomQueue <int>(); for (int i = 0; i < 10; i++) { queue.Enqueue(i); } queue.Clear(); Assert.AreEqual(0, queue.Count()); }
public void Clear_CorrectParamsSting_CountBecomesZero() { string[] arr = { "af", "re", "lo" }; CustomQueue <string> queue = new CustomQueue <string>(arr); int expected = 0; queue.Clear(); int actual = queue.Count; Assert.AreEqual(expected, actual); }
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); }
public void CustomQueue_ClearTest() { CustomQueue<int> myQueue = new CustomQueue<int>(); for (int i = 0; i < 10; i++) { myQueue.Enqueue(i); } myQueue.Clear(); int expected = 0; Assert.AreEqual(expected, myQueue.Count); }
public void TestClear_NonEmptyQueue() { CustomQueue <int> queue = new CustomQueue <int>(); int queueCount = 10; for (int i = 0; i < queueCount; i++) { queue.Enqueue(i); } queue.Clear(); Assert.AreEqual(0, queue.Count); }
public void ClearTestMethod() { var queue = new CustomQueue <int>(); queue.Enqueue(10); queue.Enqueue(20); queue.Enqueue(30); queue.Enqueue(40); queue.Enqueue(50); var expectedQueue = new int[] { }; queue.Clear(); var actualQueue = queue.ToArray(); CollectionAssert.AreEqual(expectedQueue, actualQueue); }
public static void Main(string[] args) { CustomQueue<int> test = new CustomQueue<int>(); for (int i = 0; i < 10; i++) { test.Enqueue(i); } int[] teter = test.ToArray(); test.Clear(); foreach (var item in teter) { Console.WriteLine(item); } }
static void Main() { try { // استک و صف همزمان Console.WriteLine("queue: "); FifoLifoList <string> fl = new FifoLifoList <string>((int)CollectionNames.Queue); fl.Add("a"); fl.Add("b"); fl.Add("c"); Console.WriteLine(fl.Remove().GetData()); Console.WriteLine(fl.Remove().GetData()); Console.WriteLine("stack: "); // استک و صف همزمان FifoLifoList <string> fl2 = new FifoLifoList <string>((int)CollectionNames.Stack); fl2.Add("a"); fl2.Add("b"); fl2.Add("c"); Console.WriteLine(fl2.Remove().GetData()); Console.WriteLine(fl2.Remove().GetData()); // (استک با پایه آرایه برای سرعت بیشتر (چون ولیو تایپ است Console.WriteLine("ArrayBasedStack: "); ArrayBasedStack <int> arbStack = new ArrayBasedStack <int>(); arbStack.Push(1); arbStack.Push(2); arbStack.Push(3); Console.WriteLine(arbStack.Pop()); Console.WriteLine(arbStack.Pop()); //--------------------------- Console.WriteLine("CustomQueue: "); CustomQueue <string> cq = new CustomQueue <string>(); cq.EnQueue("a"); cq.EnQueue("b"); cq.EnQueue("c"); Console.WriteLine(cq.DeQueue().GetData()); Console.WriteLine(cq.DeQueue().GetData()); cq.Clear(); //Console.WriteLine(cq.DeQueue().Data); Console.WriteLine("CustomStack: "); CustomStack <int> numbers = new CustomStack <int>(); numbers.Push(1); numbers.Push(2); numbers.Push(3); numbers.Push(4); numbers.Push(5); numbers.PrintAll(); Console.WriteLine("Count of stack is: {0}", numbers.Count()); Console.WriteLine("Popping {0}", numbers.PopData()); Console.WriteLine("Popping {0}", numbers.PopData()); numbers.Clear(); //Console.WriteLine("Popping '{0}'", numbers.Pop2()); //------------------- CustomStack <string> stack = new CustomStack <string>(); stack.Push("first"); stack.Push("second"); stack.Push("third"); Console.WriteLine("\nall data"); stack.PrintAll(); Console.WriteLine("\nPeek"); Console.WriteLine(stack.PeekFromStack().GetData()); Console.WriteLine("\nPrintAll again"); stack.PrintAll(); Console.WriteLine("\nnow try to pop"); Console.WriteLine(stack.Pop().GetData()); Console.WriteLine("\nPrintAll again"); stack.PrintAll(); Console.WriteLine("\nnow try to popping two items "); Console.WriteLine("Popping {0}", stack.Pop().GetData()); Console.WriteLine("Popping {0}", stack.Pop().GetData()); Console.WriteLine("\nPrintAll again"); stack.PrintAll(); Console.WriteLine("\nPush three item"); stack.Push("first"); stack.Push("second"); stack.Push("third"); stack.PrintAll(); } catch (Exception e) { Console.WriteLine(e.Message); } }
public void Queue_Clear_Test() { queue.Clear(); Assert.IsTrue(queue.Count == 0); }