-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/JA-112 BrowseServiceTests #102
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Test - GetBrowseAdsPage_WhenRequestIsInvalid_ShouldReturnUnsuccessfulResponse
Tests: - GetBrowseAdsPage_WhenPageNumberIsLargerThanAvailable_ShouldReturnLastPage - GetBrowseAdsPage_WhenRequestIsValid_ShouldReturnCorrectNumberOfAds - GetBrowseAdsPage_WhenRequestIsValid_ShouldReturnCorrectTotalPages - GetBrowseAdsPage_WhenRequestIsValid_ShouldReturnCorrectAds
Tests: - GetAdDetails_WhenAdDoesntExist_ShouldReturnNull - GetAdDetails_WhenUserIsOwner_ShouldReturnCorrectUserRelationship - GetAdDetails_WhenUserIsAcceptedStudent_ShouldReturnCorrectUserRelationship - GetAdDetails_WhenUserIsPendingStudent_ShouldReturnCorrectUserRelationship - GetAdDetails_WhenUserIsHasNoRelationshipToAd_ShouldReturnCorrectUserRelationship - GetAdDetails_WhenAdExists_ShouldReturnCorrectAdDetails Also added 1 helper method - SetupMockGetAdById
- GetUsersSchedule_WhenUserHasNoAds_ShouldReturnEmptyTutorsSchedule - GetUsersSchedule_WhenUserHasNoScheduleItemRequests_ShouldReturnEmptyStudentsSchedule - GetUsersSchedule_WhenUserHasAdsWithScheduleItems_ShouldReturnCorrectTutorsSchedule - GetUsersSchedule_WhenUserHasScheduleItemRequests_ShouldReturnCorrectStudentsSchedule - GetUsersSchedule_WhenNoStudentIsAccepted_ShouldReturnNullAcceptedStudentsName - GetUsersSchedule_WhenAStudentIsAccepted_ShouldReturnStudentsName - GetUsersSchedule_WhenRequestIsAccepted_ShouldReturnCorrectStatus - GetUsersSchedule_WhenRequestIsPending_ShouldReturnCorrectStatus Also added and modified some helper methods.
- Change in method name - Fixed incorrect assertion - Spacing adjustments - Added and renamed some actual and expected variables
skrawus
approved these changes
May 29, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
).