Improved test for C# roll_the_die

See automatically closed PR Improved test for roll_the_die by nash8114 · Pull Request #2354 · exercism/csharp · GitHub

  • Tests now check whether multiple rolls supply different results
  • RollDie is checked for returning all values in the expected range
  • Increased for-loop from 100 times to 1000 times to prevent false negative. Encountered that 100 rolls was not sufficient to have all numbers in range(1, 18) to be generated.

Rationale:

My first implementation (thanks XKCD) made the test suite pass.

public int RollDie()
{
  return 4; // chosen by fair dice roll.
            // guaranteed to be random.
}
1 Like

I’ll look at it soon!

No problem with that solution at all.

Also tests check if multiple rolls supply different results, but there is a seed that you can provide that will also not provide different results.

You also encountered reality of random numbers the other way, where you also can not guarantee that all numbers will be encountered even given 5 times the number of rolls multiplied by the number of values.

All of these things can and should be discussed in the mentoring phase, and potentially brought up as “Things to Think About” after successful completion of the exercise.

The tests are not meant to be exhaustive, and so it is not surprising that you found something that made you question the thoroughness of hte tests though.

That said… “Thank you for your work and participation and wanting to improve Exercism!”