@@ -18,7 +18,7 @@ public sealed class CollectionAssert
1818 {
1919 private const string CollectionEqualReason = "{0}({1})" ;
2020 private const string NumberOfElementsDiff = "Different number of elements." ;
21- private const string ElementsAtIndexDontMatch = "Element at index {0} do not match." ;
21+ private const string ElementsAtIndexDontMatch = "Element at index {0} do not match. Expected:<{1}>. Actual:<{2}>. " ;
2222 private const string BothCollectionsSameReference = "Both collection references point to the same collection object. {0}" ;
2323 private const string BothCollectionsSameElements = "Both collection contain same elements." ;
2424
@@ -120,14 +120,17 @@ private static bool AreCollectionsEqual(
120120 ICollection actual ,
121121 ref string reason )
122122 {
123- if ( expected != actual )
123+ if ( expected
124+ != actual )
124125 {
125- if ( expected == null || actual == null )
126+ if ( expected == null
127+ || actual == null )
126128 {
127129 return false ;
128130 }
129131
130- if ( expected . Count != actual . Count )
132+ if ( expected . Count
133+ != actual . Count )
131134 {
132135 reason = NumberOfElementsDiff ;
133136 return false ;
@@ -138,13 +141,21 @@ private static bool AreCollectionsEqual(
138141
139142 int num = 0 ;
140143
141- while ( enumerator . MoveNext ( ) && enumerator2 . MoveNext ( ) )
144+ while ( enumerator . MoveNext ( )
145+ && enumerator2 . MoveNext ( ) )
142146 {
143- if ( ! object . Equals ( enumerator . Current , enumerator2 . Current ) )
147+ if ( ! object . Equals (
148+ enumerator . Current ,
149+ enumerator2 . Current ) )
144150 {
145151 reason = string . Format (
146152 ElementsAtIndexDontMatch ,
147- new object [ 1 ] { num } ) ;
153+ new object [ 3 ]
154+ {
155+ num ,
156+ enumerator . Current ,
157+ enumerator2 . Current
158+ } ) ;
148159
149160 return false ;
150161 }
@@ -157,9 +168,8 @@ private static bool AreCollectionsEqual(
157168 return true ;
158169 }
159170
160- reason = string . Format (
161- BothCollectionsSameReference ,
162- new object [ 1 ] { string . Empty } ) ;
171+ reason = string . Format ( BothCollectionsSameReference ,
172+ new object [ 1 ] { string . Empty } ) ;
163173
164174 return true ;
165175 }
0 commit comments