Skip to content
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

AnyOfTypes.System.Text.Json : Fixed matching types on nested objects #19

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
?
  • Loading branch information
StefH committed Jul 19, 2024
commit dc7b10c43d86c24bbd2951ef56eee878afc2f22a
17 changes: 16 additions & 1 deletion tests/AnyOfTests/AnyOfConverterTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,22 @@ public void ConvertFrom_ShouldReturnExpectedValue(object value, object expectedV
var converter = new AnyOfConverter<string, int>();

// Act
var result = (AnyOf<string, int>)converter.ConvertFrom(_typeDescriptorContext, null!, value);
var result = (AnyOf<string, int>)converter.ConvertFrom(_typeDescriptorContext, null!, value)!;

// Assert
result.CurrentValue.Should().Be(expectedValue);
}

[Theory]
[InlineData(42, 42)]
[InlineData("foo", "foo")]
public void ConvertFrom_UsingTypeDescriptor_ShouldReturnExpectedValue(object value, object expectedValue)
{
// Arrange
var converter = TypeDescriptor.GetConverter(typeof(AnyOfConverter<string, int>));

// Act
var result = (AnyOf<string, int>)converter.ConvertFrom(_typeDescriptorContext, null!, value)!;

// Assert
result.CurrentValue.Should().Be(expectedValue);
Expand Down