Skip to content

Create Activout.RestClient.Test.Json project to test both JSON implementations#82

Merged
twogood merged 2 commits intomainfrom
copilot/fix-81
Jul 29, 2025
Merged

Create Activout.RestClient.Test.Json project to test both JSON implementations#82
twogood merged 2 commits intomainfrom
copilot/fix-81

Conversation

Copy link
Contributor

Copilot AI commented Jul 28, 2025

This PR creates a new Activout.RestClient.Test.Json project that runs the same JSON-dependent test cases against both Activout.RestClient.Json (System.Text.Json) and Activout.RestClient.Newtonsoft.Json implementations.

Changes Made

  • New test project: Created Activout.RestClient.Test.Json with xUnit framework
  • Dual JSON support: Added project references to both JSON implementation libraries
  • Parameterized tests: Used [Theory] and [InlineData] attributes to run tests with both implementations
  • Shared test models: Created implementation-agnostic models and interfaces in the MovieReviews namespace
  • Test coverage: Ported key tests from existing projects:
    • RestClientTests - Core REST client functionality with JSON serialization/deserialization
    • SerializationOrderTest - Tests serialization ordering behavior
    • SimpleValueObjectTest - Tests simple value object handling

Implementation Details

The solution uses a JsonImplementation enum to parameterize tests across both implementations:

public enum JsonImplementation
{
    SystemTextJson,
    NewtonsoftJson
}

[Theory]
[InlineData(JsonImplementation.SystemTextJson)]
[InlineData(JsonImplementation.NewtonsoftJson)]
public async Task TestPostJsonAsync(JsonImplementation jsonImplementation)
{
    // Test runs with both implementations
}

Each test creates the appropriate REST client builder based on the implementation:

return jsonImplementation switch
{
    JsonImplementation.SystemTextJson => builder.WithSystemTextJson(),
    JsonImplementation.NewtonsoftJson => builder.WithNewtonsoftJson(),
    _ => throw new ArgumentOutOfRangeException(nameof(jsonImplementation))
};

Test Results

All 25 tests pass successfully with both JSON implementations, ensuring compatibility and consistent behavior across both libraries.

Fixes #81.


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

… for both JSON implementations

Co-authored-by: twogood <[email protected]>
Copilot AI changed the title [WIP] Create a new Activout.RestClient.Test.Json project to run the same tests against both JSON implementations Create Activout.RestClient.Test.Json project to test both JSON implementations Jul 28, 2025
Copilot AI requested a review from twogood July 28, 2025 20:42
@twogood twogood marked this pull request as ready for review July 28, 2025 20:57
@twogood twogood merged commit c5b67da into main Jul 29, 2025
8 checks passed
@twogood twogood deleted the copilot/fix-81 branch July 29, 2025 06:22
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.

Create a new Activout.RestClient.Test.Json project to run the same tests against both JSON implementations

2 participants