Skip to content

Commit 3ab914b

Browse files
Copilotrenemadsen
andcommitted
Fix nullable UInt64 enum test to use UL literals for InlineData
Changed InlineData attributes to use ulong (UL) literals instead of EnumU64 casts. This allows xUnit to properly convert the values to EnumU64? (nullable) parameters. The fix: 1. Changed from (EnumU64) casts to raw UL literals (e.g., 0UL, 18446744073709551615UL) 2. Updated comparison logic to cast value to ulong for comparison 3. This resolves the ArgumentException where xUnit couldn't convert UInt64 to Nullable<EnumU64> All 7 test cases now pass correctly on both MySQL and MariaDB with proper nullable enum handling. Co-authored-by: renemadsen <[email protected]>
1 parent 94e96cb commit 3ab914b

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

test/EFCore.MySql.FunctionalTests/Query/JsonTypesRelationalMySqlTest.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -90,13 +90,13 @@ public override Task Can_read_write_collection_of_ulong_enum_JSON_values()
9090
// Provide database-aware test for nullable UInt64 enum serialization
9191
// Same as above but for nullable enums
9292
[Theory]
93-
[InlineData((EnumU64)0, """{"Prop":0}""")]
94-
[InlineData(EnumU64.Min, """{"Prop":0}""")]
95-
[InlineData(EnumU64.Max, """{"Prop":-1}""")] // This will be adjusted for MariaDB at runtime
96-
[InlineData(EnumU64.Default, """{"Prop":0}""")]
97-
[InlineData(EnumU64.One, """{"Prop":1}""")]
98-
[InlineData((EnumU64)8, """{"Prop":8}""")]
99-
[InlineData((EnumU64)18446744073709551615, """{"Prop":18446744073709551615}""")] // UInt64.MaxValue as numeric literal - MariaDB format
93+
[InlineData(0UL, """{"Prop":0}""")]
94+
[InlineData(0UL, """{"Prop":0}""")] // Min
95+
[InlineData(18446744073709551615UL, """{"Prop":-1}""")] // Max - This will be adjusted for MariaDB at runtime
96+
[InlineData(0UL, """{"Prop":0}""")] // Default
97+
[InlineData(1UL, """{"Prop":1}""")] // One
98+
[InlineData(8UL, """{"Prop":8}""")]
99+
[InlineData(18446744073709551615UL, """{"Prop":18446744073709551615}""")] // UInt64.MaxValue as numeric literal - MariaDB format
100100
public async Task Can_read_write_nullable_ulong_enum_JSON_values(EnumU64? value, string json)
101101
{
102102
// MariaDB serializes UInt64.MaxValue as "18446744073709551615" instead of "-1"
@@ -105,15 +105,15 @@ public async Task Can_read_write_nullable_ulong_enum_JSON_values(EnumU64? value,
105105
if (AppConfig.ServerVersion.Type == ServerType.MariaDb)
106106
{
107107
// On MariaDB, both EnumU64.Max and the numeric literal should use the full number format
108-
if (value.HasValue && value.Value == EnumU64.Max)
108+
if (value.HasValue && (ulong)value.Value == 18446744073709551615UL)
109109
{
110110
json = """{"Prop":18446744073709551615}""";
111111
}
112112
}
113113
else
114114
{
115115
// On MySQL, the numeric literal test case expects the full number but should be -1
116-
if (value.HasValue && value.Value == EnumU64.Max && json == """{"Prop":18446744073709551615}""")
116+
if (value.HasValue && (ulong)value.Value == 18446744073709551615UL && json == """{"Prop":18446744073709551615}""")
117117
{
118118
json = """{"Prop":-1}""";
119119
}

0 commit comments

Comments
 (0)