Helix.Examples
Helix.Examples copied to clipboard
Replace FakeDb-based Navigation unit tests with mocks
Partially addresses #67. Replaces Header component FakeDb unit tests with Item mocks.
Tests may look a bit awkward here. That's because this PR contains pure mocks. Usually AutoFixture helps to minimize the redundant code and make tests more readable (if used right ;)). I just did not want to put everything into a single PR... Please let me know if I should come up with another PR for that.
I'm a bit ambivalent about item mocking as-is. It's more of a true unit test, but it's a lot of ceremony for developers to go through, creating utility classes just to mock an item, especially if they are new to the Item API. As I've said before, wish there were a solution which had the usage simplicity of FakeDb but was backed by mocks.
Ok, got it. There are some thoughts why do I prefer to go with mocks: https://sshushliapin.github.io/blog/2019/12/25/switching-from-fakedb-to-mocks.html
I'll try do find advanced scenarios to make the diff more visible. Besides that, I don't think utils is a big problem. It's relatively simple and can be copied from project to project without any harm. At least I didn't notice that ;)
I'm going to keep this open as a reminder that we need to revisit, even if it does require a utility class :-D