Skip to content

Conversation

@akovylyaeva
Copy link
Contributor

No description provided.

@akovylyaeva akovylyaeva requested a review from a team December 22, 2025 12:01

public async Task<long> ExecuteAsync(CreateWorkEntryCommandParams createWorkEntryCommandParams)
{
var project = _assignmentsApi.FindEmployeeProjectAsync(createWorkEntryCommandParams.ProjectId);
Copy link
Contributor

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);
Copy link
Contributor

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
Copy link
Contributor

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);
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants