I have a handful of controllers and each controller has a test class with unit tests. Each unit test calls a single action and verifies that the action handles a given scenario.
The test class has a setup routine that instantiates a number of fake repositories and other fake objects. The fake repositories have static collections that the repository methods/functions operate against.
It is working pretty well but I'm running into some challenges:
When entities in one fake collection reference entities in another fake collection the code in the repository's constructor explodes and becomes difficult to manage
When a unit test calls an action that modifies the fake repository data, the static collection changes state making it nearly impossible to operate against that same data in other unit tests
So I have two questions that might require you to also explain your general approach:
How do you go about setting up a fake collection for an entity that references other fake collections/entities?
Do your fake repositories support update/insert/delete operations? If so, how do you prevent changes from one unit test from impacting another unit test?