Exemplo n.º 1
0
        public void ValidateGeneratedNumbers()
        {
            var gen1 = new NumberGenerator();

            var result = gen1.GenerateXNumbers(1);

            Assert.AreEqual(Constants.MatrixNumberOfRows, result.Length);
            Assert.IsTrue(result.All(r => r >= 10 && r <= 19));
            Assert.AreEqual(result.Length, result.Distinct().Count());


            result = gen1.GenerateXNumbers(0);
            Assert.AreEqual(Constants.MatrixNumberOfRows, result.Length);
            Assert.IsTrue(result.All(r => r >= 0 && r <= 9));
            Assert.AreEqual(result.Length, result.Distinct().Count());


            result = gen1.GenerateXNumbers(8);
            Assert.AreEqual(Constants.MatrixNumberOfRows, result.Length);
            Assert.IsTrue(result.All(r => r >= 80 && r <= 89));
            Assert.AreEqual(result.Length, result.Distinct().Count());

            var gen2 = new NumberGenerator();

            result = gen2.GenerateWinningIndexes();
            Assert.AreEqual(result.Length, Constants.NumberOfWinningOptions);
            Assert.IsTrue(result.All(r => r >= 0 && r < Constants.MatrixNumberOfColumns * Constants.MatrixNumberOfRows));
            Assert.AreEqual(result.Length, result.Distinct().Count());
        }
Exemplo n.º 2
0
 private static void GenerateRandomMatrix(NumberGenerator generator)
 {
     for (var colNumber = 0; colNumber < Constants.MatrixNumberOfColumns; colNumber++)
     {
         var numbers = generator.GenerateXNumbers(colNumber);
         for (var index = 0; index < Constants.MatrixNumberOfRows; index++)
         {
             State.GeneratedNumbers[colNumber * 3 + index] = numbers[index];
         }
     }
 }