Esempio n. 1
0
        public void NextReturnsTopOfIntQueue()
        {
            TestRandom rand = new TestRandom();
            rand.IntQueue.Enqueue(101);

            Assert.AreEqual(101, rand.Next(), "The result of Next should have been the top of the IntQueue");
        }
Esempio n. 2
0
        public void NextPopsTheTopOfTheIntQueue()
        {
            TestRandom rand = new TestRandom();
            rand.IntQueue.Enqueue(0);

            if(rand.IntQueue.Count != 1)
                Assert.Fail("Unable to determine the size of IntQueue.");

            rand.Next();

            Assert.AreEqual(0, rand.IntQueue.Count, "The number of items left in IntQueue should be zero.");
        }
Esempio n. 3
0
        public void NextMinMaxTruncatesValueInIntQueueMin()
        {
            TestRandom rand = new TestRandom();
            rand.IntQueue.Enqueue(-1);
            int minValue = 0;

            int result = rand.Next(minValue, 100);

            Assert.AreEqual(minValue, result, "The result should have been equal to minValue because the min value represents an inclusive lower bound.");
        }
Esempio n. 4
0
        public void NextMinMaxTruncatesValueInIntQueueMax()
        {
            TestRandom rand = new TestRandom();
            rand.IntQueue.Enqueue(101);
            int maxValue = 100;

            int result = rand.Next(0, maxValue);

            Assert.AreEqual(maxValue - 1, result, "The result should have been (maxvalue - 1) because the max value represents an exclusive upper bound.");
        }
Esempio n. 5
0
        public void NextMinMaxReturnsNextItemInIntQueue()
        {
            TestRandom rand = new TestRandom();
            rand.IntQueue.Enqueue(100);

            int result = rand.Next(0, 101);

            Assert.AreEqual(100, result);
        }
Esempio n. 6
0
        public void NextMinMaxPopsIntQueue()
        {
            TestRandom rand = new TestRandom();
            rand.IntQueue.Enqueue(100);

            if(rand.IntQueue.Count != 1)
                Assert.Fail("Unable to determine the size of IntQueue.");

            rand.Next(0, 101);

            Assert.AreEqual(0, rand.IntQueue.Count, "The number of items in IntQueue should be zero.");
        }