public void CustomQueue_Contains_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);

            Assert.IsTrue(customQueue.Contains(4));
            Assert.IsFalse(customQueue.Contains(18));
        }
示例#2
0
        public void GeneralFunctionalityWithPointEquatable()
        {
            CustomQueue <Point> customQueue = new CustomQueue <Point>();

            customQueue.Add(new Point(2, 4));
            customQueue.Add(new Point(1, 8));
            Assert.AreEqual(customQueue, new[] { new Point(2, 4), new Point(1, 8) });

            customQueue.Get();
            Assert.AreEqual(customQueue, new[] { new Point(1, 8) });

            Assert.AreEqual(customQueue.Peek(), new Point(1, 8));
            Assert.AreEqual(customQueue.Count, 1);
            Assert.IsTrue(customQueue.Contains(new Point(1, 8)));
            Assert.IsFalse(customQueue.Contains(new Point(2, 4)));
        }
示例#3
0
        public void GeneralFunctionalityBCLTypesInt()
        {
            CustomQueue <int> customQueue = new CustomQueue <int>();

            customQueue.Add(5);
            customQueue.Add(15);
            Assert.AreEqual(customQueue, new[] { 5, 15 });

            customQueue.Get();
            Assert.AreEqual(customQueue, new[] { 15 });

            Assert.AreEqual(customQueue.Peek(), 15);
            Assert.AreEqual(customQueue.Count, 1);
            Assert.IsTrue(customQueue.Contains(15));
            Assert.IsFalse(customQueue.Contains(5));
        }
        public void ContainsShouldReturnFalseIfItemWeAreLookingForIsNotInQueue()
        {
            //Arange
            var queue = new CustomQueue <int>();

            //Act
            queue.Enqueue(1);
            //Assert
            Assert.AreEqual(false, queue.Contains(2));
        }
        public void ContainsShouldReturnTrueIfWeAddOneAndThenLookForIt()
        {
            //Arange
            var queue = new CustomQueue <int>();

            //Act
            queue.Enqueue(1);
            //Assert
            Assert.AreEqual(true, queue.Contains(1));
        }
        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);
        }
        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);
        }
示例#8
0
        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);
        }
示例#9
0
        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));
        }
示例#10
0
        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);
        }
示例#11
0
        public void GeneralFunctionalityWithArrayList()
        {
            CustomQueue <ArrayList> customQueue = new CustomQueue <ArrayList>();

            customQueue.Add(new ArrayList()
            {
                2
            });
            customQueue.Add(new ArrayList()
            {
                "Hello"
            });
            Assert.AreEqual(customQueue, new[] { new ArrayList()
                                                 {
                                                     2
                                                 }, new ArrayList()
                                                 {
                                                     "Hello"
                                                 } });

            customQueue.Get();
            Assert.AreEqual(customQueue, new[] { new ArrayList()
                                                 {
                                                     "Hello"
                                                 } });

            Assert.AreEqual(customQueue.Peek(), new ArrayList()
            {
                "Hello"
            });
            Assert.AreEqual(customQueue.Count, 1);
            Assert.IsFalse(customQueue.Contains(new ArrayList()
            {
                "Hello"
            }));
            Assert.IsFalse(customQueue.Contains(new ArrayList()
            {
                2
            }));
        }
示例#12
0
        public bool Equals(CustomQueue <T> x, CustomQueue <T> y)
        {
            if (ReferenceEquals(x, null) && ReferenceEquals(y, null))
            {
                return(true);
            }
            if (ReferenceEquals(x, null) || ReferenceEquals(y, null))
            {
                return(false);
            }

            return(x.Count == y.Count && x.All(item => y.Contains(item, EqualityComparer <T> .Default)));
        }
        public void Contains_CorrectParamsInt_ReturnsTrueIfContains()
        {
            List <int> list = new List <int> {
                1, 2, 3, 4
            };
            CustomQueue <int> queue = new CustomQueue <int>(list);

            bool expected = true;

            bool actual = queue.Contains(3);

            Assert.AreEqual(expected, actual);
        }
示例#14
0
        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);
        }
示例#15
0
 public void Queue_Contains_Test()
 {
     Assert.IsTrue(queue.Contains("two") == true);
 }
示例#16
0
 public void Contains()
 {
     CustomQueue<double> queue = new CustomQueue<double>();
     queue.EnQueue(3.14);
     queue.EnQueue(8.28);
     queue.EnQueue(1.1987);
     queue.EnQueue(5.39);
     Assert.AreEqual(true, queue.Contains(1.1987));
 }