Moq has been around for a while and Mole has replaced by Fakes.
Fakes touches on Stub and Shim. In this short code I will just discuss stub at this point of time.
Download the sample from https://www.box.com/s/461b521f53e64ce9d7e9.
You will find an Interface IRepository.cs.
You cannot test the Interface if there does not implement. In VS 2012 there is a Fakes Framework you can make your Interface to become stub.
When you open ItemBusinessTest.cs yon can find the TestMethod below.
public void ItSaves()
bool result = false;
StubIRepository repository = new StubIRepository();
repository.SaveItem = (Item item) => result = true;
var itemBusiness = new ItemBusiness(repository);
itemBusiness.Save(new Item(“Test Item”, 1));
Realize that if you do not use the Fakes then the code below is will not work.
IRepository repository = new IRepository();