by Groxx · 15y ago · 0 comments
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. 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.My questions with TDD always come with the refactoring.