Beispiel #1
0
        public void Die_RollDie_ValueShouldBeInSixSidedDieRange()
        {
            // Arrange
            var die = new Die();

            // This is not deterministic, but for 100 rolls, the result should be in the correct range all the time
            for (int i = 0; i < 100; i++)
            {
                // Act
                var rollResult = die.Roll();

                // Assert
                die.Value.Should().BeInRange(1, 6);
                die.Value.Should().Be(rollResult);
            }
        }
Beispiel #2
0
        public void Die_RollDie_ValueFrequencyShouldBeRelativelyEvenlyDistributed()
        {
            // Arrange
            var die = new Die();
            var rolls = new int[7] { 0, 0, 0, 0, 0, 0, 0 };

            // This is not completely deterministic, but given 100 rolls, each valid value (1, 2, 3, 4, 5, 6) should happen at least 5 times each
            for (int i = 0; i < 100; i++)
            {
                // Act
                rolls[die.Roll()]++;
            }

            // Assert
            rolls[0].Should().Be(0);
            for (int i = 1; i <= 6; i++)
            {
                rolls[i].Should().BeGreaterOrEqualTo(5);
            }
        }