Esempio n. 1
0
        public void testingThatLastDigitsRemovedCorrectly(int drawSize, int drawPool, int result, int[] frequency)
        {
            LastDigitHandler lastDigitHandler = new LastDigitHandler(drawPool);
            NumberGenerator  numberGenerator  = new NumberGenerator(drawSize, drawPool);

            numberGenerator.generateList(new List <int>(), 0, 1, numberGenerator.highestStartPoint, false);
            Exclusions lastDigitExclusions = new Exclusions();

            lastDigitExclusions.lastDigitExclusions = frequency;
            numberGenerator.exclusions = lastDigitExclusions;
            int numRemoved = 0;

            for (int i = 0; i < 10; i++)
            {
                lastDigitHandler.endingDigit = i;
                numRemoved += lastDigitHandler.getFrequencyOfOccurrence(numberGenerator.numberCollection, frequency[0]);
                numRemoved += lastDigitHandler.getFrequencyOfOccurrence(numberGenerator.numberCollection, frequency[1]);
            }
            numberGenerator.numberCollection = new List <List <int> >();
            numberGenerator.generateList(new List <int>(), 0, 1, numberGenerator.highestStartPoint, true);
            result = result - numRemoved;
            Assert.Equal(result, numberGenerator.numberCollection.Count);
        }
Esempio n. 2
0
        public void getFrequencyOfOccurrenceTest()
        {
            LastDigitHandler lastDigitHandler = new LastDigitHandler(60);
            List <int>       test1            = new List <int> {
                1, 11, 21, 22, 32, 43
            };
            List <int> test2 = new List <int> {
                5, 7, 9, 11, 13, 15
            };
            List <int> test3 = new List <int> {
                1, 11, 21, 23, 32, 43
            };
            List <int> test4 = new List <int> {
                5, 15, 25, 35, 45, 55
            };
            List <List <int> > testCollection = new List <List <int> > {
                test1, test2, test3, test4
            };

            lastDigitHandler.endingDigit = 1;
            Assert.Equal(0, lastDigitHandler.getFrequencyOfOccurrence(testCollection, 6));
            Assert.Equal(0, lastDigitHandler.getFrequencyOfOccurrence(testCollection, 5));
            Assert.Equal(0, lastDigitHandler.getFrequencyOfOccurrence(testCollection, 4));
            Assert.Equal(2, lastDigitHandler.getFrequencyOfOccurrence(testCollection, 3));
            Assert.Equal(0, lastDigitHandler.getFrequencyOfOccurrence(testCollection, 2));
            Assert.Equal(1, lastDigitHandler.getFrequencyOfOccurrence(testCollection, 1));
            Assert.Equal(1, lastDigitHandler.getFrequencyOfOccurrence(testCollection, 0));

            lastDigitHandler.endingDigit = 2;
            Assert.Equal(0, lastDigitHandler.getFrequencyOfOccurrence(testCollection, 6));
            Assert.Equal(0, lastDigitHandler.getFrequencyOfOccurrence(testCollection, 5));
            Assert.Equal(0, lastDigitHandler.getFrequencyOfOccurrence(testCollection, 4));
            Assert.Equal(0, lastDigitHandler.getFrequencyOfOccurrence(testCollection, 3));
            Assert.Equal(1, lastDigitHandler.getFrequencyOfOccurrence(testCollection, 2));
            Assert.Equal(1, lastDigitHandler.getFrequencyOfOccurrence(testCollection, 1));
            Assert.Equal(2, lastDigitHandler.getFrequencyOfOccurrence(testCollection, 0));

            lastDigitHandler.endingDigit = 3;
            Assert.Equal(0, lastDigitHandler.getFrequencyOfOccurrence(testCollection, 6));
            Assert.Equal(0, lastDigitHandler.getFrequencyOfOccurrence(testCollection, 5));
            Assert.Equal(0, lastDigitHandler.getFrequencyOfOccurrence(testCollection, 4));
            Assert.Equal(0, lastDigitHandler.getFrequencyOfOccurrence(testCollection, 3));
            Assert.Equal(1, lastDigitHandler.getFrequencyOfOccurrence(testCollection, 2));
            Assert.Equal(2, lastDigitHandler.getFrequencyOfOccurrence(testCollection, 1));
            Assert.Equal(1, lastDigitHandler.getFrequencyOfOccurrence(testCollection, 0));

            lastDigitHandler.endingDigit = 5;
            Assert.Equal(1, lastDigitHandler.getFrequencyOfOccurrence(testCollection, 6));
            Assert.Equal(0, lastDigitHandler.getFrequencyOfOccurrence(testCollection, 5));
            Assert.Equal(0, lastDigitHandler.getFrequencyOfOccurrence(testCollection, 4));
            Assert.Equal(0, lastDigitHandler.getFrequencyOfOccurrence(testCollection, 3));
            Assert.Equal(1, lastDigitHandler.getFrequencyOfOccurrence(testCollection, 2));
            Assert.Equal(0, lastDigitHandler.getFrequencyOfOccurrence(testCollection, 1));
            Assert.Equal(2, lastDigitHandler.getFrequencyOfOccurrence(testCollection, 0));
        }