@@ -18,7 +18,7 @@ public sealed class CollectionAssert
18
18
{
19
19
private const string CollectionEqualReason = "{0}({1})" ;
20
20
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}>. " ;
22
22
private const string BothCollectionsSameReference = "Both collection references point to the same collection object. {0}" ;
23
23
private const string BothCollectionsSameElements = "Both collection contain same elements." ;
24
24
@@ -120,14 +120,17 @@ private static bool AreCollectionsEqual(
120
120
ICollection actual ,
121
121
ref string reason )
122
122
{
123
- if ( expected != actual )
123
+ if ( expected
124
+ != actual )
124
125
{
125
- if ( expected == null || actual == null )
126
+ if ( expected == null
127
+ || actual == null )
126
128
{
127
129
return false ;
128
130
}
129
131
130
- if ( expected . Count != actual . Count )
132
+ if ( expected . Count
133
+ != actual . Count )
131
134
{
132
135
reason = NumberOfElementsDiff ;
133
136
return false ;
@@ -138,13 +141,21 @@ private static bool AreCollectionsEqual(
138
141
139
142
int num = 0 ;
140
143
141
- while ( enumerator . MoveNext ( ) && enumerator2 . MoveNext ( ) )
144
+ while ( enumerator . MoveNext ( )
145
+ && enumerator2 . MoveNext ( ) )
142
146
{
143
- if ( ! object . Equals ( enumerator . Current , enumerator2 . Current ) )
147
+ if ( ! object . Equals (
148
+ enumerator . Current ,
149
+ enumerator2 . Current ) )
144
150
{
145
151
reason = string . Format (
146
152
ElementsAtIndexDontMatch ,
147
- new object [ 1 ] { num } ) ;
153
+ new object [ 3 ]
154
+ {
155
+ num ,
156
+ enumerator . Current ,
157
+ enumerator2 . Current
158
+ } ) ;
148
159
149
160
return false ;
150
161
}
@@ -157,9 +168,8 @@ private static bool AreCollectionsEqual(
157
168
return true ;
158
169
}
159
170
160
- reason = string . Format (
161
- BothCollectionsSameReference ,
162
- new object [ 1 ] { string . Empty } ) ;
171
+ reason = string . Format ( BothCollectionsSameReference ,
172
+ new object [ 1 ] { string . Empty } ) ;
163
173
164
174
return true ;
165
175
}
0 commit comments