Unit Testing & Fake Repository implementation with cascading CRUD operations
Posted
by Erik Ashepa
on Stack Overflow
See other posts from Stack Overflow
or by Erik Ashepa
Published on 2010-05-20T21:29:06Z
Indexed on
2010/05/21
1:00 UTC
Read the original article
Hit count: 541
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.
© Stack Overflow or respective owner