Open dyllandry opened 1 year ago
Here's an SO that might help: https://stackoverflow.com/questions/63479986/rust-mocking-rand-functions-with-gen-range
Even though this issue isn't huge value add, it is a good learning opportunity for mocking traits.
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()
.