4 ms·
I see what they're trying to say, and I like the increased decoupling with FakeItEasy (I'll probably switch to it), but every single test in there makes a call
by Groxx 16y ago
I see what they're trying to say, and I like the increased decoupling with FakeItEasy (I'll probably switch to it), but every single test in there makes a call that depends on parameter type and order.
For instance. Every test includes a line like this:
var user = new UserRepository(store, encryption)...
Later, there are lines like this:
A.CallTo(() => encryption.CheckPassword("Ghanima", "Duncan"))).MustHaveHappened();
How is that not identical? The faking code is more flexible, as you can fake any kind of call without regard to the parameters or types, but that's just as tightly bound as the other examples, and they'll all fail if you re-order the parameters.
- latch 16y agoThe test that you picked is specifically there to test that call. Did you not see: Any.CallTo(store).WithReturnType<User>().Returns(user); Also, two of the tests have seen been updated to truly leverage FakeItEasy's stubbing capabilities: [Test] public void ReturnsNullIfThePasswordsDontMatch() { var store = A.Fake<IDataStore>(); var encryption = A.Fake<IEncryption>(); A.CallTo(() => encryption.CheckPassword(null, null)).WithAnyArguments().Returns(false); var user = new UserRepository(store, encryption).FindByCredentials(null, null); Assert.IsNull(user) } There's no setup/expectation on the store - it'll just returned a canned (default new user) response.
- angryjim 16y agoI agree with this point. You are using a more flexible stubbing framework and THAT is what the point of this post should be about. The rest is just semantics. My questions with TDD always come with the refactoring.