Verifying the repository calls into the DB context

A good place to start is verifying that the system is fully integrated; let's first test that the repository can access the database. Create a folder within the integration test project called RepositoryTests and create a new test file called GetAll. This will be where the integration tests for the GetAll method of the repository will be created.

You could create a test that verifies that the repository can be created, like so:

[Fact]
public void ItExists()
{
var options = new DbContextOptions<SpeakerMeetContext>();
var context = new SpeakerMeetContext(options);

var repository = new Repository.Repository<Speaker>(context);
}

However, that's not going to pass. If you run the test you will receive the following error:

System.InvalidOperationException: No database provider has been configured for this DbContext.

This is easily fixed by configuring an appropriate provider.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.226.185.196