Exemplo n.º 1
0
        public void Damage_rolls_within_expected_ranges()
        {
            var  asys       = new AttackSystem();
            bool rolled_min = false;
            bool rolled_max = false;

            for (int i = 0; i < 1000; i++)
            {
                int damage = asys.RollDamage(bfh_impact);
                if (damage == 6)
                {
                    rolled_min = true;
                }
                if (damage == 16)
                {
                    rolled_max = true;
                }
                Assert.That(damage, Is.GreaterThanOrEqualTo(6));
                Assert.That(damage, Is.LessThanOrEqualTo(16));
            }

            // Technically a nondeterministic test, so, technically, evil.
            Assert.That(rolled_min, "the probability of not rolling min in 1000 is 5.8e-13, or odds of 1.7 trillion to one.");
            Assert.That(rolled_max, "the probability of not rolling max in 1000 is 5.8e-13, or odds of 1.7 trillion to one.");
        }