I'm doing a small practice project to improve my unit testing skills. I'm using Entity Framework Code First.
I'm using a FakeDBSet, which works well for simple lists of entities. When entity trees are returned things aren't so nice. In particular two way relationships aren't maintained as this is part of the Entity Framework magic.
I have two classes:
public class Book
{
public virtual ICollection<Review> Reviews {get; set;}
}
public class Review
{
public virtual Book Book { get; set;}
}
If I set the book for a review, the review does not get added to the book's review collection. It does when using EF, but not in my fake version.
Is there a way mock this behaviour, or should I not rely on EF to implement two way relationships? Or is mocking the data context just a waste of time?