File tree Expand file tree Collapse file tree
CSharpFunctionalExtensions.Tests/ValueObjectTests
CSharpFunctionalExtensions/ValueObject Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -82,10 +82,10 @@ public void GivenNullOrEmptyKey_WhenCreating_ThenException(string key)
8282 [ InlineData ( "Four" , false ) ]
8383 [ InlineData ( nameof ( TestEnumValueObject . Two ) , true ) ]
8484 [ InlineData ( nameof ( TestEnumValueObject . One ) , true ) ]
85- public void GivenPossibleKey_WhenCheckingIfKeyIsEnumValueObject_ThenShouldReturnTrueIfKeyRecognized ( string possibleKey , bool isIn )
85+ public void GivenPossibleKey_WhenCheckingIfKeyIsEnumValueObject_ThenShouldReturnTrueIfKeyRecognized ( string possibleId , bool isIn )
8686 {
8787 // Act
88- var isEnumValueObject = TestEnumValueObject . Is ( possibleKey ) ;
88+ var isEnumValueObject = TestEnumValueObject . Is ( possibleId ) ;
8989
9090 // Assert
9191 isEnumValueObject . Should ( ) . Be ( isIn ) ;
Original file line number Diff line number Diff line change @@ -65,7 +65,15 @@ public static Maybe<TEnumeration> FromName(string name)
6565 ? EnumerationsByName [ name ]
6666 : null ;
6767 }
68-
68+
69+ public static IReadOnlyCollection < TEnumeration > All = EnumerationsById . Values ;
70+
71+ public static bool Is ( string possibleName ) => All . Select ( e => e . Name ) . Contains ( possibleName ) ;
72+
73+ public static bool Is ( TId possibleId ) => All . Select ( e => e . Id ) . Contains ( possibleId ) ;
74+
75+ public override string ToString ( ) => Name ;
76+
6977 protected override IEnumerable < object > GetEqualityComponents ( )
7078 {
7179 yield return Id ;
@@ -98,7 +106,7 @@ protected EnumValueObject(string id)
98106 Id = id ;
99107 }
100108
101- public static IEnumerable < TEnumeration > All = Enumerations . Values ;
109+ public static IReadOnlyCollection < TEnumeration > All = Enumerations . Values ;
102110
103111 public virtual string Id { get ; protected set ; }
104112
@@ -139,7 +147,7 @@ public static Maybe<TEnumeration> FromId(string id)
139147 : null ;
140148 }
141149
142- public static bool Is ( string possibleKey ) => All . Select ( e => e . Id ) . Contains ( possibleKey ) ;
150+ public static bool Is ( string possibleId ) => All . Select ( e => e . Id ) . Contains ( possibleId ) ;
143151
144152 public override string ToString ( ) => Id ;
145153
You can’t perform that action at this time.
0 commit comments