Ejemplo n.º 1
0
        public void PopulateTableWithSymbolsProbabilitySumMoreThanHundred()
        {
            SlotMachine slotMachine = new SlotMachine(Configuration.RowCount, Configuration.ColCount);
            var         list        = new List <Symbol>()
            {
                new Symbol(character: '$', coefficient: 1.5M, probability: 1.5)
            };

            Assert.ThrowsException <ProbabilityException>(() => slotMachine.PopulateTableWithSymbols(list));
        }
Ejemplo n.º 2
0
        public void PopulateTableWithSymbolsCheckProbability()
        {
            SlotMachine slotMachine = new SlotMachine(rowsCount: 1, colsCount: 10000);
            var         table       = slotMachine.PopulateTableWithSymbols(Configuration.Symbols);
            var         grouping    = table[0].ToLookup(x => x.Character);

            foreach (var item in Configuration.Symbols)
            {
                Symbol[] firstRow    = table[0];
                double   count       = grouping[item.Character].Count();
                double   probability = count / firstRow.Length;
                Assert.AreEqual(expected: item.Probability, actual: probability, delta: 0.01);
            }
        }