I am working on an ASP.Net Core MVC Web application.
My Solution contains 2 projects:
- One for the application and
- A second project, dedicated to unit tests (XUnit).
I have added a reference to the application project in the Tests project.
What I want to do now is to write a class in the XUnit Tests project which will communicate with the database through entity framework.
What I was doing in my application project was to access to my DbContext
class through constructor dependency injection.
But I cannot do this in my tests project, because I have no Startup.cs
file. In this file I can declare which services will be available.
So what can I do to get a reference to an instance of my DbContext
in the test class?