Mocking an Entity Framework(EF6)
This following section explain how you can easily unit test Microsoft Entity Framework with TypeMock Isolator
and provides the following samples:
Example for DbContext class:
Original Method
The following sample includes the classes which we will use in the samples.
C# public class BloggingContext : DbContext { public DbSet<Blog> Blogs { get; set; } } public class Blog { public int BlogId { get; set; } public string Name { get; set; } }
VB
Public Class BloggingContext
Inherits DbContext
Public Property Blogs() As DbSet(Of Blog)
Private m_Blogs As DbSet(Of Blog)
End Class
Public Class Blog
Public Property BlogId() As Integer
Public Property Name()
End Class