public void ShouldReturnNumberInSingleNumberArray()
        {
            int[] numbers = new int[] { 1 };
            UniqueRandomNumberGenerator g = new UniqueRandomNumberGenerator(numbers);

            int number = 0;
            
            while (g.RemainingNumbersCount > 0)
            {
                number = g.NewRandomNumber();
            }

            int expected = numbers[0];
            int actual = number;

            Assert.AreEqual(expected, actual);
        }
        public void ShouldReturnNumberInSingleNumberRange()
        {
            int minNumber = 2;
            int maxNumber = 2;

            UniqueRandomNumberGenerator g = new UniqueRandomNumberGenerator(minNumber, maxNumber);

            int number = 0;
            
            while (g.RemainingNumbersCount > 0)
            {
                number = g.NewRandomNumber();
            }

            int expected = minNumber;
            int actual = number;

            Assert.AreEqual(expected, actual);
        }
        public void ShouldReturnEquivalentBagToNumberArray()
        {
            int[] numbers = new int[] { 1, 2, 3, 4, 3, 6, 4, 8, 17, 42, 6 };
            ConcurrentBag<int> expected = new ConcurrentBag<int>(numbers);
            ConcurrentBag<int> actual = new ConcurrentBag<int>();

            UniqueRandomNumberGenerator g = new UniqueRandomNumberGenerator(numbers);

            while (g.RemainingNumbersCount > 0)
            {
                int number = g.NewRandomNumber();
                actual.Add(number);
            }

            CollectionAssert.IsEmpty(
                actual.Except(expected), 
                "The bag of random numbers differs from the bag corresponding to the initial array.");
        }
        public void MinimumNumberInRangeGreaterThanMaximumNumber()
        {
            int minNumber = 3;
            int maxNumber = 2;

            UniqueRandomNumberGenerator g = new UniqueRandomNumberGenerator(minNumber, maxNumber);
        }
        public void ShouldReturnProperSubsetOfNumberRange()
        {
            int minNumber = 3;
            int maxNumber = 15;

            UniqueRandomNumberGenerator g = new UniqueRandomNumberGenerator(minNumber, maxNumber);

            ReadOnlyCollection<int> numbers = g.RemainingNumbers;
            HashSet<int> initialSet = new HashSet<int>(numbers);

            const int GeneratedRandomNumberCount = 3;

            // Sanity check on test data
            Debug.Assert(
                GeneratedRandomNumberCount < initialSet.Count,
                String.Format("The generated random number count {0} must be less than the count of initial numbers {1} for this test.", GeneratedRandomNumberCount, initialSet.Count));

            Debug.WriteLine("Random Numbers");
            int number = 0;

            HashSet<int> actual = new HashSet<int>();
            for (int i = 1; i <= GeneratedRandomNumberCount; i++)
            {
                number = g.NewRandomNumber();
                actual.Add(number);
            }

            Assert.IsTrue(
                actual.IsProperSubsetOf(initialSet),
                "Generated numbers should be a subset of the set corresponding to the initial range.");
        }
        public void ShouldReturnProperSubsetOfNumberArray()
        {
            int[] numbers = new int[] { 1, 2, 3, 4, 3, 6, 4, 8, 17, 42, 6 };
            ConcurrentBag<int> initialBag = new ConcurrentBag<int>(numbers);
            UniqueRandomNumberGenerator g = new UniqueRandomNumberGenerator(numbers);
            const int GeneratedRandomNumberCount = 3;

            // Sanity check on test data
            Debug.Assert(
                GeneratedRandomNumberCount < initialBag.Count,
                String.Format("The generated random number count {0} must be less than the count of initial numbers {1} for this test.", GeneratedRandomNumberCount, initialBag.Count));

            Debug.WriteLine("Random Numbers");
            int number = 0;

            ConcurrentBag<int> actualBag = new ConcurrentBag<int>();

            for (int i = 1; i <= GeneratedRandomNumberCount; i++)
            {
                number = g.NewRandomNumber();
                actualBag.Add(number);
            }

            HashSet<int> initialSet = new HashSet<int>(initialBag.AsEnumerable());
            HashSet<int> actualSet = new HashSet<int>(actualBag.AsEnumerable());

            Assert.IsTrue(
                actualSet.IsProperSubsetOf(initialSet),
                "Generated numbers should be a subset of the initial numbers.");
        }