Skip to content

Commit 1460bc8

Browse files
committed
Fix test case
1 parent d876908 commit 1460bc8

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

UnitsNet.Tests/UnitConverterTest.cs

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
// Copyright (c) 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com).
22
// https://github.com/angularsen/UnitsNet
3-
//
3+
//
44
// Permission is hereby granted, free of charge, to any person obtaining a copy
55
// of this software and associated documentation files (the "Software"), to deal
66
// in the Software without restriction, including without limitation the rights
77
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
88
// copies of the Software, and to permit persons to whom the Software is
99
// furnished to do so, subject to the following conditions:
10-
//
10+
//
1111
// The above copyright notice and this permission notice shall be included in
1212
// all copies or substantial portions of the Software.
13-
//
13+
//
1414
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1515
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1616
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@@ -50,9 +50,9 @@ public void ConvertByName_UnitTypeCaseInsensitive()
5050

5151
[Theory]
5252
[InlineData(1, "UnknownQuantity", "Meter", "Centimeter")]
53-
public void ConvertByName_ThrowsQuantityNotFoundExceptionOnUnknownQuantity(double inputValue, string quantityTypeName, string fromUnit, string toUnit)
53+
public void ConvertByName_ThrowsUnitNotFoundExceptionOnUnknownQuantity(double inputValue, string quantityTypeName, string fromUnit, string toUnit)
5454
{
55-
Assert.Throws<QuantityNotFoundException>(() => UnitConverter.ConvertByName(inputValue, quantityTypeName, fromUnit, toUnit));
55+
Assert.Throws<UnitNotFoundException>(() => UnitConverter.ConvertByName(inputValue, quantityTypeName, fromUnit, toUnit));
5656
}
5757

5858
[Theory]
@@ -132,4 +132,4 @@ public void TryConvertByAbbreviation_ReturnsTrueOnSuccessAndOutputsResult(double
132132
Assert.Equal(expectedValue, result);
133133
}
134134
}
135-
}
135+
}

UnitsNet/UnitConverter.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -115,17 +115,17 @@ public static bool TryConvert(QuantityValue fromValue, Enum fromUnitValue, Enum
115115
/// <exception cref="AmbiguousUnitParseException">More than one unit matches the abbreviation.</exception>
116116
public static double ConvertByName(FromValue fromValue, string quantityName, string fromUnit, string toUnit)
117117
{
118-
if (!TryGetUnitType(quantityName, out var unitType))
118+
if (!TryGetUnitType(quantityName, out Type unitType))
119119
throw new UnitNotFoundException($"The unit type for the given quantity was not found: {quantityName}");
120120

121-
if (!TryParseUnit(unitType, fromUnit, out var fromUnitValue)) // ex: LengthUnit.Meter
121+
if (!TryParseUnit(unitType, fromUnit, out Enum fromUnitValue)) // ex: LengthUnit.Meter
122122
{
123123
var e = new UnitNotFoundException($"Unit not found [{fromUnit}].");
124124
e.Data["unitName"] = fromUnit;
125125
throw e;
126126
}
127127

128-
if (!TryParseUnit(unitType, toUnit, out var toUnitValue)) // ex: LengthUnit.Centimeter
128+
if (!TryParseUnit(unitType, toUnit, out Enum toUnitValue)) // ex: LengthUnit.Centimeter
129129
{
130130
var e = new UnitNotFoundException($"Unit not found [{toUnit}].");
131131
e.Data["unitName"] = toUnit;

0 commit comments

Comments
 (0)