@@ -40,7 +40,7 @@ private enum Flags : byte
4040 D = 0x8 ,
4141 // ReSharper disable once InconsistentNaming
4242 CD = C | D ,
43- Dx = D | 0x20
43+ Dx = D | 0x20 ,
4444 }
4545
4646 private const Flags Ab = Flags . A | Flags . B ;
@@ -77,15 +77,15 @@ private enum NoFlags : byte
7777 private const NoFlags EfU = NoFlags . E | NoFlags . F | NoFlagsUndef ;
7878 // ReSharper restore BitwiseOperatorOnEnumWithoutFlags
7979
80- public enum NameDescEnum
80+ public enum NameDescEnum : long
8181 {
8282 [ Display ( Name = "Field 1" , Description = "Field 1 Desc" ) ]
83- Field1 ,
83+ Field1 = long . MinValue ,
8484
8585 [ Display ]
86- Field2 ,
86+ Field2 = 0 ,
8787
88- Field3
88+ Field3 = long . MaxValue
8989 }
9090 #endregion
9191
@@ -425,5 +425,21 @@ public static void TestSetOrClearFlag()
425425 [ TestCase ( NameDescEnum . Field2 , ExpectedResult = "Field2" ) ]
426426 [ TestCase ( NameDescEnum . Field3 , ExpectedResult = "Field3" ) ]
427427 public string TestGetDisplay ( NameDescEnum value ) => EnumHelper . GetEnumValue ( value ) . ToString ( ) ;
428+
429+ [ Test ]
430+ public void TestNegativeValues ( )
431+ {
432+ IsTrue ( EnumHelper . IsDefined ( NameDescEnum . Field1 ) ) ;
433+ IsFalse ( EnumHelper . IsFlagsEnum < NameDescEnum > ( ) ) ;
434+ AreEqual (
435+ NameDescEnum . Field1 ,
436+ EnumHelper . TryParse < NameDescEnum > ( nameof ( NameDescEnum . Field1 ) ) ) ;
437+ AreEqual (
438+ NameDescEnum . Field1 ,
439+ EnumHelper . TryParse < NameDescEnum > ( long . MinValue . ToString ( ) ) ) ;
440+ AreEqual (
441+ "Field2, Field3, Field1" ,
442+ EnumHelper . GetNameValues < NameDescEnum > ( ) . Select ( kvp => kvp . Key ) . Join ( ", " ) ) ;
443+ }
428444 }
429445}
0 commit comments