-
Notifications
You must be signed in to change notification settings - Fork 0
feat: #7: add mock assignments api to get projects list #14
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
base: master
Are you sure you want to change the base?
Conversation
…and add tests for it
…malineCore/inner-circle-time-api into feature/#7-add-mock-assignments-api
Api/Features/Tracking/GetWorkEntriesByPeriod/GetWorkEntriesByPeriodHandler.cs
Outdated
Show resolved
Hide resolved
Api/Features/Tracking/GetWorkEntriesByPeriod/GetWorkEntriesByPeriodHandler.cs
Outdated
Show resolved
Hide resolved
|
|
||
| public async Task<long> ExecuteAsync(CreateWorkEntryCommandParams createWorkEntryCommandParams) | ||
| { | ||
| var project = _assignmentsApi.FindEmployeeProjectAsync(createWorkEntryCommandParams.ProjectId); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the project retrieval and check should be done in handler, not in command
| var createWorkEntryCommand = new CreateWorkEntryCommand(context, mockClaimsProvider); | ||
| var mockAssignmentsApi = GetMockAssignmentsApi(); | ||
|
|
||
| var createWorkEntryCommand = new CreateWorkEntryCommand(context, mockClaimsProvider, mockAssignmentsApi); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The creation logic becomes more and more complicated here. Consider using DI for CreateWorkEntryCommand instantiation instead of creating it manually
| @@ -0,0 +1,21 @@ | |||
| namespace Application.ExternalDeps.AssignmentsApi; | |||
|
|
|||
| public static class ProjectsMock | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the purpose of this class? I think we can just add the static readonly ProjectsResponse ProjectsData to the AssignmentsApi directly
| .Setup(api => api.FindEmployeeProjectAsync(It.IsAny<long>())) | ||
| .Returns((long projectId) => | ||
| { | ||
| return ProjectsMock.ProjectsMockData.Projects.Find(x => x.Id == projectId); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The ProjectsMock.ProjectsMockData.Projects seems long and repetitive. Something like AssignmentsMock.Projects.Find... would be easier to read. Also, we probably don't need to create Mock<IAssignmentsApi>() here, since we only have one implementation that already returns mocked data
…malineCore/inner-circle-time-api into feature/#7-add-mock-assignments-api
No description provided.