Skip to content

Commit

Permalink
Use ToString by default for arguments in display names (#1378)
Browse files Browse the repository at this point in the history
  • Loading branch information
thomhurst authored Dec 9, 2024
1 parent f591edd commit 4708df2
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions TUnit.Core/Helpers/ArgumentFormatter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,24 @@ public static string GetConstantValue(TestContext testContext, object? o)
{
return "null";
}

var toString = o.ToString()!;

if (o is Enum @enum)
if (o is Enum)
{
return @enum.ToString();
return toString;
}

if (o.GetType().IsPrimitive || o is string)
{
return o.ToString()!;
return toString;
}

return o.GetType().Name;
if (toString == o.GetType().FullName)
{
return o.GetType().Name;
}

return toString;
}
}

0 comments on commit 4708df2

Please sign in to comment.