-
Notifications
You must be signed in to change notification settings - Fork 1
Associated with EntityFrameworkCore
NightAngell edited this page Feb 16, 2019
·
9 revisions
You can use this features both with HubUnitTestsWithEF and HubUnitTestsWithEF<T, TDbContext>
//By default, pure TDbContext mock, without any setup.
public Mock<TDbContext> DbContextMock;
For example we have Hub which is dependend from DbContext. However We testing method which not use that DbContext. So better not initialize entire in memory database (remember, My In memory databases are lazy loaded) when we dont need it and instead use mock (which is also lazy loaded).
//Relational database in memory.
//During instance creation it ensure if db is created.
//https://docs.microsoft.com/pl-pl/ef/core/miscellaneous/testing/sqlite
public TDbContext DbInMemorySqlite;
//Database in memory (not really relational).
//During instance creation it ensure if db is created.
//https://docs.microsoft.com/pl-pl/ef/core/miscellaneous/testing/in-memory
public TDbContext DbInMemory;