From 4708df2a565091fc64f12a8b6cd9e0bbaa6e9c19 Mon Sep 17 00:00:00 2001 From: Tom Longhurst <30480171+thomhurst@users.noreply.github.com> Date: Mon, 9 Dec 2024 19:27:31 +0000 Subject: [PATCH] Use ToString by default for arguments in display names (#1378) --- TUnit.Core/Helpers/ArgumentFormatter.cs | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/TUnit.Core/Helpers/ArgumentFormatter.cs b/TUnit.Core/Helpers/ArgumentFormatter.cs index feee93f58e..660892a392 100644 --- a/TUnit.Core/Helpers/ArgumentFormatter.cs +++ b/TUnit.Core/Helpers/ArgumentFormatter.cs @@ -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; } } \ No newline at end of file