@@ -141,6 +141,58 @@ public void TestDictionaryKeysNotAddedInOrder()
141141            if  ( ! result . AreEqual ) 
142142                throw  new  Exception ( result . DifferencesString ) ; 
143143        } 
144+ 
145+         // Enum for use as dictionary key 
146+         private  enum  PersonType 
147+         { 
148+             Employee , 
149+             Manager , 
150+             Contractor 
151+         } 
152+ 
153+         [ Test ] 
154+         public  void  TestDictionaryWithEnumKey_Positive ( ) 
155+         { 
156+             Person  p1  =  new  Person  {  Name  =  "Alice" ,  DateCreated  =  DateTime . Now  } ; 
157+             Person  p2  =  new  Person  {  Name  =  "Bob" ,  DateCreated  =  DateTime . Now . AddDays ( - 1 )  } ; 
158+ 
159+             var  dict1  =  new  Dictionary < PersonType ,  Person > 
160+             { 
161+                 {  PersonType . Employee ,  p1  } , 
162+                 {  PersonType . Manager ,  p2  } 
163+             } ; 
164+             var  dict2  =  new  Dictionary < PersonType ,  Person > 
165+             { 
166+                 {  PersonType . Employee ,  p1  } , 
167+                 {  PersonType . Manager ,  p2  } 
168+             } ; 
169+ 
170+             var  result  =  _compare . Compare ( dict1 ,  dict2 ) ; 
171+             if  ( ! result . AreEqual ) 
172+                 throw  new  Exception ( result . DifferencesString ) ; 
173+         } 
174+ 
175+         [ Test ] 
176+         public  void  TestDictionaryWithEnumKey_Negative ( ) 
177+         { 
178+             Person  p1  =  new  Person  {  Name  =  "Alice" ,  DateCreated  =  DateTime . Now  } ; 
179+             Person  p2  =  new  Person  {  Name  =  "Bob" ,  DateCreated  =  DateTime . Now . AddDays ( - 1 )  } ; 
180+             Person  p3  =  new  Person  {  Name  =  "Charlie" ,  DateCreated  =  DateTime . Now . AddDays ( - 2 )  } ; 
181+ 
182+             var  dict1  =  new  Dictionary < PersonType ,  Person > 
183+             { 
184+                 {  PersonType . Employee ,  p1  } , 
185+                 {  PersonType . Manager ,  p2  } 
186+             } ; 
187+             var  dict2  =  new  Dictionary < PersonType ,  Person > 
188+             { 
189+                 {  PersonType . Employee ,  p1  } , 
190+                 {  PersonType . Manager ,  p3  } 
191+             } ; 
192+ 
193+             var  result  =  _compare . Compare ( dict1 ,  dict2 ) ; 
194+             Assert . IsFalse ( result . AreEqual ) ; 
195+         } 
144196        #endregion
145197    } 
146198} 
0 commit comments