Skip to content

Commit

Permalink
update test case and fix some formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
WeihanLi committed Jul 31, 2024
1 parent f906cbb commit 5ec8c18
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2168,7 +2168,12 @@ public async Task IgnoreConditionWhenWritingDefault_WinsOver_IgnoreReadOnlyField
[Fact]
public async Task JsonIgnoreCondition_WhenWriting()
{
var json = await Serializer.SerializeWrapper(new JsonIgnoreCondition_WhenReadingWritingTestModel{ Age = 10, Name = "Mike" });
var options = new JsonSerializerOptions { IgnoreReadOnlyProperties = true };
var json = await Serializer.SerializeWrapper
(
new JsonIgnoreCondition_WhenReadingWritingTestModel { Age = 10, Name = "Mike" },
options
);
Assert.Equal("""{"Age":10}""", json);
}

Expand All @@ -2182,7 +2187,7 @@ public async Task JsonIgnoreCondition_WhenReading()
}

public class JsonIgnoreCondition_WhenReadingWritingTestModel
{
{
[JsonIgnore(Condition = JsonIgnoreCondition.WhenReading)]
public int Age { get; set; }
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWriting)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ public override async Task HonorJsonPropertyName_PrivateGetter()
Assert.Equal(MySmallEnum.AnotherValue, obj.GetProxy());

// JsonInclude for private members not supported in source gen
await Assert.ThrowsAsync<InvalidOperationException>(async() => await Serializer.SerializeWrapper(obj));
await Assert.ThrowsAsync<InvalidOperationException>(async () => await Serializer.SerializeWrapper(obj));
}

[Fact]
Expand Down Expand Up @@ -331,7 +331,8 @@ public override async Task ClassWithIgnoredAndPrivateMembers_DoesNotIncludeIgnor
[JsonSerializable(typeof(IDiamondInterfaceHierarchyWithNamingConflict.IJoinInterface), TypeInfoPropertyName = "IDiamondInterfaceHierarchyWithNamingConflictIJoinInterface")]
[JsonSerializable(typeof(IDiamondInterfaceHierarchyWithNamingConflictUsingAttribute.IJoinInterface), TypeInfoPropertyName = "IDiamondInterfaceHierarchyWithNamingConflictUsingAttributeIJoinInterface")]
[JsonSerializable(typeof(CollectionWithPrivateElementType))]
[JsonSerializable(typeof(DictionaryWithPrivateKeyAndValueType))][JsonSerializable(typeof(ClassWithIgnoredAndPrivateMembers))]
[JsonSerializable(typeof(DictionaryWithPrivateKeyAndValueType))]
[JsonSerializable(typeof(ClassWithIgnoredAndPrivateMembers))]
[JsonSerializable(typeof(ClassWithInternalJsonIncludeProperties))]
[JsonSerializable(typeof(ClassWithIgnoredAndPrivateMembers))]
[JsonSerializable(typeof(ClassUsingIgnoreWhenWritingDefaultAttribute))]
Expand Down

0 comments on commit 5ec8c18

Please sign in to comment.