From 2ff586e28e7523f6d3d775587efefd2616e77b9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E6=94=BF=E9=81=93?= Date: Thu, 19 Dec 2024 15:30:58 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=8D=95=E5=85=83=E6=B5=8B?= =?UTF-8?q?=E8=AF=95=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/dotnetCampus.OpenXMLUnitConverter/MillisecondTime.cs | 3 +-- .../MillisecondTimeTest.cs | 3 ++- 2 files changed, 3 insertions(+), 3 deletions(-) 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/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); });