Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I created tests for
BrowseService
.There's a lot of code here. I tried to do as much of Arrange in helper methods as I could without making it more confusing.
Please check my setup code closely, because it's something that we'll have to do for all services probably.
I struggled a bit with setting up the in memory EF Core db (method
SetupInMemoryDbContext
), but it works quite nicely. Notice that I useGuid.NewGuid()
in thedatabaseName
parameter. It's to give it a unique name each time the tests run (it's realy realy unlikely we'd get 2 Guids that are the same). We need it, because when the tests run in parallel, if 2 or more contexts are initialized with the same dbName they share the same db and tests are not isolated. Before I figured it out, I could not understand why my tests failed when I ran them all, but were successful when I tried to debug them.Look also at my methods that set up repository mocks (e.g.
SetupMockGetAllAds
).