Verify that the service calls the DB through the repository

Moving on to the business layer, you should verify that each service can retrieve data from the InMemory database through the repository.

First, create a new folder in the integration test project called ServiceTests. Within that folder, create a folder named SpeakerServiceTests. This folder is where the tests specific to the SpeakerService will be created.

Create a new test file named GetAll. Add a test method to verify that the service can be created:

[Fact]
public void ItExists()
{
var options = new DbContextOptionsBuilder<SpeakerMeetContext>()
.UseInMemoryDatabase("SpeakerMeetInMemory")
.Options;

var context = new SpeakerMeetContext(options);

var repository = new Repository<Speaker>(context);
var gravatarService = new GravatarService();

var speakerService = new SpeakerService(repository, gravatarService);
}
..................Content has been hidden....................

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