diff --git a/src/dotnetCampus.OpenXMLUnitConverter/MillisecondTime.cs b/src/dotnetCampus.OpenXMLUnitConverter/MillisecondTime.cs index f0ef3a1..4c82e26 100644 --- a/src/dotnetCampus.OpenXMLUnitConverter/MillisecondTime.cs +++ b/src/dotnetCampus.OpenXMLUnitConverter/MillisecondTime.cs @@ -26,8 +26,7 @@ public MillisecondTime(StringValue? millisecond) Milliseconds = value; IsIndefinite = false; } - else if (Enum.TryParse(millisecond, true, out var result) - && result == IndefiniteTimeDeclarationValues.Indefinite) + else if (new IndefiniteTimeDeclarationValues(millisecond) == IndefiniteTimeDeclarationValues.Indefinite) { Milliseconds = long.MaxValue; IsIndefinite = true; diff --git a/src/dotnetCampus.OpenXmlUnitConverter/dotnetCampus.OpenXmlUnitConverter.csproj b/src/dotnetCampus.OpenXmlUnitConverter/dotnetCampus.OpenXmlUnitConverter.csproj index 4aa3f69..5ebc6a5 100644 --- a/src/dotnetCampus.OpenXmlUnitConverter/dotnetCampus.OpenXmlUnitConverter.csproj +++ b/src/dotnetCampus.OpenXmlUnitConverter/dotnetCampus.OpenXmlUnitConverter.csproj @@ -20,7 +20,7 @@ all runtime; build; native; contentfiles; analyzers; buildtransitive - + diff --git a/tests/dotnetCampus.OpenXmlUnitConverter.Tests/MillisecondTimeTest.cs b/tests/dotnetCampus.OpenXmlUnitConverter.Tests/MillisecondTimeTest.cs index 584ce2d..2bde6be 100644 --- a/tests/dotnetCampus.OpenXmlUnitConverter.Tests/MillisecondTimeTest.cs +++ b/tests/dotnetCampus.OpenXmlUnitConverter.Tests/MillisecondTimeTest.cs @@ -32,7 +32,8 @@ public void ParseMillisecondTimeText() "传入未定义的 OpenXML 字符串,可以说明未解析".Test(() => { - var stringValue = new StringValue(IndefiniteTimeDeclarationValues.Indefinite.ToString()); + var indefinite = (IEnumValue)IndefiniteTimeDeclarationValues.Indefinite; + var stringValue = new StringValue(indefinite.Value); var millisecondTime = new MillisecondTime(stringValue); Assert.AreEqual(true, millisecondTime.IsIndefinite); });