Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

All implementations of IStrategy should test input cells are not modified #10

Open
mmmcaffeine opened this issue Nov 18, 2021 · 0 comments
Labels
testing There are missing test cases

Comments

@mmmcaffeine
Copy link
Owner

Currently we're using bool?[] to represent cells, but passed as IEnumerable<bool?>. It would be possible for an implementation of IStrategyto cast this to the specific type and fiddle with the content. We do not want to allow this. Managing the state of any grid would be the responsibility of any kind ofGameorPuzzle` type, not the strategy itself.

It might make sense to implement this behaviour in StrategyBase. That type could take a copy of the input array and pass that to the template method. That would guarantee inheritors cannot modify the original because they never see it. That way we only have to implement the tests for one type, rather than every implementation.

This might become a non-issue if we implement Line (#1) and Hint (#2); we'd expect to implement those as immutable types so implementations of IStrategy would have a hard time changing them 😉

@mmmcaffeine mmmcaffeine added the testing There are missing test cases label Nov 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
testing There are missing test cases
Projects
None yet
Development

No branches or pull requests

1 participant