Unit Testing & Fake Repository implementation with cascading CRUD operations
- by Erik Ashepa
Hi, i'm having trouble writing integration tests which use a fake repository,
For example : Suppose I have a classroom entity, which aggregates students...
var classroom = new Classroom();
classroom.Students.Add(new Student("Adam"));
_fakeRepository.Save(classroom);
_fakeRepostiory.GetAll<Student>().Where((student) => student.Name == "Adam"));
// This query will return null...
When using my real implementation for repository (NHibernate based), the above code works (because the save operation would cascade to the student added at the previous line),
Do you know of any fake repository implementation which support this behaviour?
Ideas on how to implement one myself?
Or do you have any other suggestions which could help me avoid this issue?
Thanks in advance,
Erik.