Ejemplo n.º 1
0
        public void InsertSweepstakes_InsertThreeSweepstakes_FirstSweepstakesAddedIsNowAtFrontOfQueue()
        {
            //Arrange
            SweepstakesQueueManager sweepstakesQueue = new SweepstakesQueueManager();
            Sweepstakes             sweepstakes1     = new Sweepstakes("this");
            Sweepstakes             sweepstakes2     = new Sweepstakes("that");
            Sweepstakes             sweepstakes3     = new Sweepstakes("the other thing");
            string expected = "this";

            //Act
            sweepstakesQueue.InsertSweepstakes(sweepstakes1);
            sweepstakesQueue.InsertSweepstakes(sweepstakes2);
            sweepstakesQueue.InsertSweepstakes(sweepstakes3);
            //Assert
            Assert.AreEqual(expected, sweepstakesQueue.Queue.Dequeue().Name);
        }
Ejemplo n.º 2
0
        public void InsertSweepstakes_InsertThreeSweepstakes_CountIsThree()
        {
            //Arrange
            SweepstakesQueueManager sweepstakesQueue = new SweepstakesQueueManager();
            Sweepstakes             sweepstakes1     = new Sweepstakes("this");
            Sweepstakes             sweepstakes2     = new Sweepstakes("that");
            Sweepstakes             sweepstakes3     = new Sweepstakes("the other thing");
            int expected = 3;

            //Act
            sweepstakesQueue.InsertSweepstakes(sweepstakes1);
            sweepstakesQueue.InsertSweepstakes(sweepstakes2);
            sweepstakesQueue.InsertSweepstakes(sweepstakes3);
            //Assert
            Assert.AreEqual(expected, sweepstakesQueue.Queue.Count);
        }
        [TestMethod] // Test 1
        // Must make underlying queue element public in order to run test
        public void Queue_Add3Sweepstakes_QueueCountIs3()
        {
            // Arrange
            SweepstakesQueueManager queue        = new SweepstakesQueueManager();
            Sweepstakes             sweepstakes1 = new Sweepstakes("1");
            Sweepstakes             sweepstakes2 = new Sweepstakes("2");
            Sweepstakes             sweepstakes3 = new Sweepstakes("3");
            int expected = 3;
            int actual;

            // Act
            queue.InsertSweepstakes(sweepstakes1);
            queue.InsertSweepstakes(sweepstakes2);
            queue.InsertSweepstakes(sweepstakes3);
            actual = queue.queue.Count;

            // Assert

            Assert.AreEqual(expected, actual);
        }
        [TestMethod] // Test 2
        // Must make underlying queue element public in order to run test
        public void Queue_Add3Sweepstakes_RemoveSweepstakes_SweepstakesIndex0IsSweepstakes2()
        {
            // Arrange
            SweepstakesQueueManager queue        = new SweepstakesQueueManager();
            Sweepstakes             sweepstakes1 = new Sweepstakes("1");
            Sweepstakes             sweepstakes2 = new Sweepstakes("2");
            Sweepstakes             sweepstakes3 = new Sweepstakes("3");
            string expected = "2";
            string actual;

            // Act
            queue.InsertSweepstakes(sweepstakes1);
            queue.InsertSweepstakes(sweepstakes2);
            queue.InsertSweepstakes(sweepstakes3);
            queue.GetSweepstakes();
            actual = queue.queue.ElementAt(0).Name;

            // Assert

            Assert.AreEqual(expected, actual);
        }