1

I am a bit confused in the usage of the keywords fake and mock depending on the various Mock/TDD frameworks.

I do understand the meaning of a mock and of a fake and per my understanding I am using this syntax right now:

// I prepare my fakes with custom expected behaviours
IUnitOfWork fakeUnitOfWork = new Mock<IUnitOfWork>();
IRepository fakeRepository = new Mock<IRepository>();

// I initialize the mock under test
MyCommandHandler mockHandler = 
   new MyCommandHandler(fakeUnitOfWork.Object, fakeRepository.Object);

// I act on my Mock
mockHandler.Handle(new Command("whatever"));

// I assert
fakeUnitOfWork.Verify(x => x.Commit(), Times.Once());
fakeRepository.Verifx(x => x.Add("whatever"), Times.Once());

Is this the correct usage of the prefix mock and fake or should I use mock for IUnitOfWork and for IRepository and MyCommandHandler is just a normal object under test?

Raffaeu
  • 6,694
  • 13
  • 68
  • 110
  • 4
    Your mocks are not fakes but mocks, your command handler is not a fake nor a mock but simply the unit under test. See duplicate. – CodeCaster Dec 08 '17 at 09:40

0 Answers0