News for hackers. Stuff that matters.
Re:Stop Using Mocks by Groxx on Wednesday March 23, 2011 @01:07PM (#2360258)
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.
Re:Stop Using Mocks by latch on Wednesday March 23, 2011 @08:19PM (#2362148)
The 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.
Re:Stop Using Mocks by angryjim on Wednesday March 23, 2011 @10:17PM (#2362517)
I 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.