Skip to content

Refactor Product API endpoints and enhance testing #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

Merged
merged 3 commits into from
Jun 10, 2025
Merged

Conversation

elbruno
Copy link
Contributor

@elbruno elbruno commented Jun 10, 2025

Refactor the ProductEndpoints class for better organization and separation of concerns by utilizing methods from ProductApiActions and ProductAiActions. Introduce new unit tests for product-related API actions, improving test coverage and organization. Update logic in ProductApiActions to ensure correct operation when updating products.

elbruno added 3 commits June 10, 2025 10:56
DETAILS

Refactored the `ProductEndpoints` class to utilize methods from `ProductApiActions` and `ProductAiActions`, enhancing code organization and separation of concerns. Updated endpoint mappings to call the new methods for retrieving, updating, creating, deleting, and searching products. Added new asynchronous methods in `ProductApiActions.cs` for handling product logic and introduced the `AISearch` method in `ProductAiActions.cs` for AI search functionality. Overall, the structure is cleaner and more maintainable.
DETAILS

- Updated `eShopLite-Aspire.sln` to include "4 Tests" project and reference for "Products.Tests".
- Modified `MSTestSettings.cs` to enable parallel test execution.
- Added `ProductApiActionsTests` class with a method to verify seeded products in `GetAllProducts`.
- Created `Products.Tests.csproj` with necessary SDK and dependencies for testing.
DETAILS

This commit introduces new unit tests in `ProductApiActionsTests.cs` to improve coverage for product-related API actions, including methods for retrieving, creating, updating, deleting, and searching for products. Each test utilizes an in-memory database with a unique name for isolation. Additionally, the `UpdateProduct` method in `ProductApiActions.cs` has been updated to fetch the existing product before applying changes, ensuring correct operation and returning a `NotFound` result if the product does not exist.
Copy link

👋 Thanks for contributing @elbruno! We will review the pull request and get back to you soon.

@elbruno elbruno merged commit 8f4f8a9 into main Jun 10, 2025
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant