Last post Mar 23, 2016 05:25 AM by jimutt
Mar 22, 2016 09:05 AM|jimutt|LINK
If you feel this topic would fit better in the EF section of the forums feel free to move it. I'm looking at unit testing for an ASP.NET 5 project where I'm running MVC 6 and EF 7 for creating a REST API backend.
I'm looking for an in-memory solution and I've been checking out the official EF7 documentation over at http://ef.readthedocs.org/en/latest/miscellaneous/testing.html?highlight=seed.
I was looking for a similar solution but in my case I'm using IdentityDbContext instead of DbContext for my DbContext class. And it seems like IdentityDbContext is only accepting an empty constructor with no parameters. Which
means I can't just add the following constructor to my own class (from the EF7 documentation):
public BloggingContext(IServiceProvider serviceProvider, DbContextOptions<BloggingContext> options)
: base(serviceProvider, options)
I'm basically looking for recommendations and ideas of how to best implement in-memory unit testing for controllers, preferably using a context class which inherits from the
Below is the current versions I'm using:
Mar 22, 2016 02:52 PM|bruce (sqlwork.com)|LINK
if you can not recode IdentityDbContext, you need to write a wrapper, say IdentityContext, that uses either a IdentityDbContext, or a InMemory database context to implement the functions. It common to use an interface to define the methods and properties.
Mar 22, 2016 04:08 PM|imran_ku07|LINK
Have you seen the tests https://github.com/aspnet/Identity/blob/5fba08562fa9151c45ea4f4d51a86f232d56dfc7/test/Microsoft.AspNetCore.Identity.EntityFrameworkCore.Test/UserStoreTest.cs
Mar 23, 2016 05:25 AM|jimutt|LINK
Thank you both, I'll be having a look at that example soon imran.