Move non-JSON tests from Activout.RestClient.Newtonsoft.Json.Test to Activout.RestClient.Test#79
Move non-JSON tests from Activout.RestClient.Newtonsoft.Json.Test to Activout.RestClient.Test#79
Conversation
Co-authored-by: twogood <[email protected]>
|
For all newly created files, use file-based namespaces and primary constructors when possible. |
…iles Co-authored-by: twogood <[email protected]>
Updated all newly created files to use file-based namespaces and primary constructors where applicable. Changes include:
All tests continue to pass. Commit fc7bb52 |
|
You say that:
But that means that 15-11=4 unit tests were not moved! I can see that three unit tests (TestTimeoutAsync, TestCancellationAsync, TestNoCancellationAsync) were not moved because |
Co-authored-by: twogood <[email protected]>
You're absolutely right about the missing tests! I found all 4 missing tests and moved them to the core project:
I added cancellation-enabled methods ( The counts are now correct:
Commit 2544ca9 |
There was a problem hiding this comment.
Pull Request Overview
This PR refactors the test architecture by moving 15 non-JSON tests from the JSON-specific test project to the core test project, improving separation of concerns and ensuring tests are located based on their actual dependencies.
- Created a new
NonJsonRestClientTestsclass in the core test project containing tests that don't require JSON serialization - Split the
IMovieReviewServiceinterface to separate core functionality from JSON-specific features - Removed non-JSON tests from the Newtonsoft.Json test project to maintain proper architectural boundaries
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| Activout.RestClient.Test/NonJsonRestClientTests.cs | New test class containing 15 moved tests for core REST functionality (DELETE, binary responses, form data, timeouts, cancellation, etc.) |
| Activout.RestClient.Test/MovieReviews/IMovieReviewService.cs | Core interface version containing only non-JSON methods including new cancellation-enabled methods |
| Activout.RestClient.Test/MovieReviews/ErrorResponse.cs | Error response class moved to support core interface error handling |
| Activout.RestClient.Newtonsoft.Json.Test/RestClientTests.cs | Removed 15 non-JSON tests that were moved to core project |
| Activout.RestClient.Newtonsoft.Json.Test/MovieReviews/IMovieReviewService.cs | JSON-specific interface version containing only methods that require JSON serialization |
Comments suppressed due to low confidence (1)
Activout.RestClient.Test/NonJsonRestClientTests.cs:46
- The timeout test is using a different endpoint (/movies/string) than the other string tests, but the mock setup expects the delay to occur on this endpoint. Consider using a dedicated timeout endpoint or ensuring the endpoint matches the intended test scenario.
.When($"{BaseUri}/movies/string")
Co-authored-by: Copilot <[email protected]> Signed-off-by: David Eriksson <[email protected]>
This PR addresses the architectural issue where unit tests for non-JSON functionality were incorrectly placed in JSON-specific test projects.
Problem
Several unit tests that use
IMovieReviewServicedon't actually require JSON serialization/deserialization, but were located inActivout.RestClient.Newtonsoft.Json.Test. These tests should be in the coreActivout.RestClient.Testproject since they test fundamental REST client functionality rather than JSON-specific features.The specific methods mentioned in the issue that don't use JSON:
[Delete("/{movieId}/reviews/{reviewId}")]- DELETE operation with no body[Get("/fail")][ErrorResponse(typeof(byte[]))]- Returns byte array, not JSON[Post("/import.csv")][ContentType("text/csv")]- Uses CSV content type, not JSONChanges Made
Moved to Core Test Project (
Activout.RestClient.Test)Created a new test class
NonJsonRestClientTestscontaining 15 tests that don't require JSON:These tests now use the core
RestClientwithout any JSON-specific configuration.Retained in JSON Test Project
The
Activout.RestClient.Newtonsoft.Json.Testproject now contains only tests that specifically require JSON functionality:Interface Separation
Split the
IMovieReviewServiceinterface:Added CancellationToken Support
Extended the core interface with cancellation-enabled methods:
GetStringCancellable(CancellationToken cancellationToken)GetByteArrayCancellable(CancellationToken cancellationToken)Testing
All tests continue to pass:
This change improves the architecture by ensuring that tests are located in the appropriate projects based on their actual dependencies, making the codebase more maintainable and the separation of concerns clearer.
Fixes #68.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.