Index: Core/Common/src/Core.Common.Gui/Converters/KeyValueAsRoundedDoubleWithoutTrailingZeroesElementAttribute.cs =================================================================== diff -u -r1ccc9e6a5966ece15014631f831604eb6058dc2c -rcf9306f3121c83f6ea21fed815245481771ada1b --- Core/Common/src/Core.Common.Gui/Converters/KeyValueAsRoundedDoubleWithoutTrailingZeroesElementAttribute.cs (.../KeyValueAsRoundedDoubleWithoutTrailingZeroesElementAttribute.cs) (revision 1ccc9e6a5966ece15014631f831604eb6058dc2c) +++ Core/Common/src/Core.Common.Gui/Converters/KeyValueAsRoundedDoubleWithoutTrailingZeroesElementAttribute.cs (.../KeyValueAsRoundedDoubleWithoutTrailingZeroesElementAttribute.cs) (revision cf9306f3121c83f6ea21fed815245481771ada1b) @@ -65,7 +65,7 @@ object unit = unitPropertyInfo.GetValue(source, new object[0]); if (unit == null) { - throw new ArgumentNullException(nameof(unit)); + throw new ArgumentException($"Unit property '{unitPropertyName}' was not of type string."); } return $"{Convert.ToString(namePropertyInfo.GetValue(source, new object[0]))} [{Convert.ToString(unit)}]"; Index: Core/Common/test/Core.Common.Gui.Test/Converters/KeyValueAsRoundedDoubleWithoutTrailingZeroesElementAttributeTest.cs =================================================================== diff -u -r8bf7f7da2ce10b6eff2263b4c0c348ba06a9e6f1 -rcf9306f3121c83f6ea21fed815245481771ada1b --- Core/Common/test/Core.Common.Gui.Test/Converters/KeyValueAsRoundedDoubleWithoutTrailingZeroesElementAttributeTest.cs (.../KeyValueAsRoundedDoubleWithoutTrailingZeroesElementAttributeTest.cs) (revision 8bf7f7da2ce10b6eff2263b4c0c348ba06a9e6f1) +++ Core/Common/test/Core.Common.Gui.Test/Converters/KeyValueAsRoundedDoubleWithoutTrailingZeroesElementAttributeTest.cs (.../KeyValueAsRoundedDoubleWithoutTrailingZeroesElementAttributeTest.cs) (revision cf9306f3121c83f6ea21fed815245481771ada1b) @@ -82,7 +82,7 @@ } [Test] - public void GetName_ValidProperties_ReturnsExpectedValu() + public void GetName_ValidProperties_ReturnsExpectedValue() { // Setup const string expectedName = "expectedName"; @@ -134,7 +134,27 @@ const string expectedMessage = "Unit property 'IDoNotExist' was not found on type TestObject."; TestHelper.AssertThrowsArgumentExceptionAndTestMessage(Call, expectedMessage); } + + [Test] + public void GetName_UnitNull_ThrowsArgumentException() + { + // Setup + var attribute = new KeyValueAsRoundedDoubleWithoutTrailingZeroesElementAttribute(nameof(TestObject.Name), + nameof(TestObject.Unit), + nameof(TestObject.Value)); + // Call + void Call() => + attribute.GetName(new TestObject + { + Unit = null + }); + + // Assert + const string expectedMessage = "Unit property 'Unit' was not of type string."; + TestHelper.AssertThrowsArgumentExceptionAndTestMessage(Call, expectedMessage); + } + [Test] [SetCulture("nl-NL")] public void GetValue_WithObjectWithRoundedDoubleProperty_ReturnsValueOfProperty()