Quantcast
Channel: ASP.NET Core
Viewing all articles
Browse latest Browse all 9386

Unit testing controllers with InMemory database and IdentityDbContext

$
0
0

Hi,

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 theIdentityDbContext interface.

Below is the current versions I'm using:

"Microsoft.AspNet.IISPlatformHandler": "1.0.0-rc1-final""Microsoft.AspNet.Mvc": "6.0.0-rc1-final","EntityFramework.Core": "7.0.0-rc1-final","Microsoft.AspNet.Identity.EntityFramework": "3.0.0-rc1-final",




Viewing all articles
Browse latest Browse all 9386

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>