So in my domain I have 3 objects. User, Item and Tag. Each user has items and tags, each item has tags and each tag has items.
The objects look a little like this:
public class User
{
public List<Item> Items { get; set; }
public List<Tag> Tags { get; set; }
}
public class Item
{
public List<Tag> Tags { get; set; }
}
public class Tag
{
public List<Item> Items { get; set;}
}
This is the first time I have a go TDD so I was wondering how do I get mocks/fakes(not sure about the right term) that I can use in my tests. At first I tried to just create some fake objects but with the many to many it seems like a lot of work.
Thanks in advance
Generally you would create an interface for all of those use those interfaces with a Mock framework:
If, for example, you use NMock, you would something like this:
This technique allows you to slice your components and place mock object and use those for testing. Also the mock framework will create temporary implementations of the interface which is very convinient.
As always, when you start with TDD and mocking, you must read this Martin Fowler article:
http://martinfowler.com/articles/mocksArentStubs.html