dyllandry / ladders-and-slides

Everyone's favourite boardgame, ladders and slides! 🪜
0 stars 0 forks source link

optionally pass in the number generator to use in roll() #1

Open dyllandry opened 1 year ago

dyllandry commented 1 year ago

https://github.com/dyllandry/ladders-and-slides/blob/fbc42c348ccd6f73d0c3c6c0369fcc78d6a68851/src/dice.rs#LL8C9-L8C41

1) The number generator can instead be generated only once before we roll any dice.

2) To make testing deterministic, we could pass in a number generator to roll().

dyllandry commented 1 year ago

Here's an SO that might help: https://stackoverflow.com/questions/63479986/rust-mocking-rand-functions-with-gen-range

dyllandry commented 1 year ago

Even though this issue isn't huge value add, it is a good learning opportunity for mocking traits.