I assume that you simply do not want to load / save any objects in your test (i.e. test only your business logic, not the save level). In this case, you will need a way to easily generate (and reuse) test stubs. The simplest way imo is to create some factories for your various objects that return some simple (but meaningful) entities.
For example, if you tested your User engine, you might want to test a factory that generates different types of users, maybe a user from Wisconsin or a user with a VERY long last name or a user without friends, against a user with 100 friends, etc.
public static class UserStubFactory { static User NewUserWithLongLastName(int letterCount) {
Then, when you create other test factories, you can start merging them. Therefore, you might want to test a user with a long last name, and then transfer them to other actions on your system. Well, now you already have TestStub, so you can just call NewUserWithLongLastName () and pass it through your engine.
If you are not from this method, you can also just create them on the fly with constructor syntax.
User newUser = new User() { LastName ="HOLYCOWTHISISAVERYYLONGLASTNAME"; }
but I prefer factories for their reuse ratio.
source share