Create an entity
Create a repository interface
Create a memory-bound repository (a.k.a. mock repository)
A membory-bound repository should inherit from MBRepositoryBase<T>, where T is an aggregate-root entity, and it should also implements the repository interface of the entity.
public class MemoryBoundOrderRepository : MBRepositoryBase<Order>, IOrderRepository
Create mock entities that are saved in the repository initially
Create the mock entities in the static constructor of the memory-bound repository.
public class MemoryBoundOrderRepository : MBRepositoryBase<Order>, IOrderRepository
{
static MemoryBoundOrderRepository()
{
}
}
Guidelines for designing an entity class
- Respond to business rule violations immediately. Check for violations as close to the code that causes it as possible.