@@ -14,7 +14,7 @@ namespace Tests
1414 public class SequenceEqual : AsyncEnumerableTests
1515 {
1616 [ Fact ]
17- public async Task SequenceEqual_Null ( )
17+ public async Task SequenceEqualAsync_Null ( )
1818 {
1919 await Assert . ThrowsAsync < ArgumentNullException > ( ( ) => AsyncEnumerable . SequenceEqualAsync ( default , Return42 ) . AsTask ( ) ) ;
2020 await Assert . ThrowsAsync < ArgumentNullException > ( ( ) => AsyncEnumerable . SequenceEqualAsync ( Return42 , default ) . AsTask ( ) ) ;
@@ -30,23 +30,40 @@ public async Task SequenceEqual_Null()
3030 }
3131
3232 [ Fact ]
33- public async Task SequenceEqual1Async ( )
33+ public async Task SequenceEqualAsync_Same ( )
34+ {
35+ var xs = new [ ] { 1 , 2 , 3 } . ToAsyncEnumerable ( ) . Select ( x => x ) ;
36+ var res = xs . SequenceEqualAsync ( xs ) ;
37+ Assert . True ( await res ) ;
38+ }
39+
40+ [ Fact ]
41+ public async Task SequenceEqualAsync_Same_IList ( )
3442 {
3543 var xs = new [ ] { 1 , 2 , 3 } . ToAsyncEnumerable ( ) ;
3644 var res = xs . SequenceEqualAsync ( xs ) ;
3745 Assert . True ( await res ) ;
3846 }
3947
4048 [ Fact ]
41- public async Task SequenceEqual2Async ( )
49+ public async Task SequenceEqualAsync_Same_Empty ( )
4250 {
4351 var xs = AsyncEnumerable . Empty < int > ( ) ;
4452 var res = xs . SequenceEqualAsync ( xs ) ;
4553 Assert . True ( await res ) ;
4654 }
4755
4856 [ Fact ]
49- public async Task SequenceEqual3Async ( )
57+ public async Task SequenceEqualAsync_NotSame ( )
58+ {
59+ var xs = new [ ] { 1 , 2 , 3 } . ToAsyncEnumerable ( ) . Select ( x => x ) ;
60+ var ys = new [ ] { 1 , 3 , 2 } . ToAsyncEnumerable ( ) . Select ( x => x ) ;
61+ var res = xs . SequenceEqualAsync ( ys ) ;
62+ Assert . False ( await res ) ;
63+ }
64+
65+ [ Fact ]
66+ public async Task SequenceEqualAsync_NotSame_IList ( )
5067 {
5168 var xs = new [ ] { 1 , 2 , 3 } . ToAsyncEnumerable ( ) ;
5269 var ys = new [ ] { 1 , 3 , 2 } . ToAsyncEnumerable ( ) ;
@@ -55,7 +72,7 @@ public async Task SequenceEqual3Async()
5572 }
5673
5774 [ Fact ]
58- public async Task SequenceEqual4Async ( )
75+ public async Task SequenceEqualAsync_NotSame_DifferentLength ( )
5976 {
6077 var xs = new [ ] { 1 , 2 , 3 , 4 } . ToAsyncEnumerable ( ) ;
6178 var ys = new [ ] { 1 , 2 , 3 } . ToAsyncEnumerable ( ) ;
@@ -64,16 +81,16 @@ public async Task SequenceEqual4Async()
6481 }
6582
6683 [ Fact ]
67- public async Task SequenceEqual5Async ( )
84+ public async Task SequenceEqualAsync_NotSame_DifferentLength_IList ( )
6885 {
69- var xs = new [ ] { 1 , 2 , 3 } . ToAsyncEnumerable ( ) ;
70- var ys = new [ ] { 1 , 2 , 3 , 4 } . ToAsyncEnumerable ( ) ;
86+ var xs = new [ ] { 1 , 2 , 3 } . ToAsyncEnumerable ( ) . Select ( x => x ) ;
87+ var ys = new [ ] { 1 , 2 , 3 , 4 } . ToAsyncEnumerable ( ) . Select ( x => x ) ;
7188 var res = xs . SequenceEqualAsync ( ys ) ;
7289 Assert . False ( await res ) ;
7390 }
7491
7592 [ Fact ]
76- public async Task SequenceEqual6Async ( )
93+ public async Task SequenceEqualAsync_Throws_Second ( )
7794 {
7895 var ex = new Exception ( "Bang!" ) ;
7996 var xs = new [ ] { 1 , 2 , 3 , 4 } . ToAsyncEnumerable ( ) ;
@@ -84,7 +101,7 @@ public async Task SequenceEqual6Async()
84101 }
85102
86103 [ Fact ]
87- public async Task SequenceEqual7Async ( )
104+ public async Task SequenceEqualAsync_Throws_First ( )
88105 {
89106 var ex = new Exception ( "Bang!" ) ;
90107 var xs = Throw < int > ( ex ) ;
@@ -95,23 +112,41 @@ public async Task SequenceEqual7Async()
95112 }
96113
97114 [ Fact ]
98- public async Task SequenceEqual8Async ( )
115+ public async Task SequenceEqualAsync_Comparer_Empty ( )
99116 {
100- var xs = new [ ] { 1 , 2 , 3 } . ToAsyncEnumerable ( ) ;
117+ var xs = AsyncEnumerable . Empty < int > ( ) ;
101118 var res = xs . SequenceEqualAsync ( xs , new Eq ( ) ) ;
102119 Assert . True ( await res ) ;
103120 }
104121
105122 [ Fact ]
106- public async Task SequenceEqual9Async ( )
123+ public async Task SequenceEqualAsync_Comparer_Same1 ( )
107124 {
108- var xs = AsyncEnumerable . Empty < int > ( ) ;
125+ var xs = new [ ] { 1 , 2 , 3 } . ToAsyncEnumerable ( ) ;
109126 var res = xs . SequenceEqualAsync ( xs , new Eq ( ) ) ;
110127 Assert . True ( await res ) ;
111128 }
112129
113130 [ Fact ]
114- public async Task SequenceEqual10Async ( )
131+ public async Task SequenceEqualAsync_Comparer_Same2 ( )
132+ {
133+ var xs = new [ ] { 1 , 2 , - 3 , 4 } . ToAsyncEnumerable ( ) . Select ( x => x ) ;
134+ var ys = new [ ] { 1 , - 2 , 3 , 4 } . ToAsyncEnumerable ( ) . Select ( x => x ) ;
135+ var res = xs . SequenceEqualAsync ( ys , new Eq ( ) ) ;
136+ Assert . True ( await res ) ;
137+ }
138+
139+ [ Fact ]
140+ public async Task SequenceEqualAsync_Comparer_NotSame ( )
141+ {
142+ var xs = new [ ] { 1 , 2 , 3 } . ToAsyncEnumerable ( ) . Select ( x => x ) ;
143+ var ys = new [ ] { 1 , 3 , 2 } . ToAsyncEnumerable ( ) . Select ( x => x ) ;
144+ var res = xs . SequenceEqualAsync ( ys , new Eq ( ) ) ;
145+ Assert . False ( await res ) ;
146+ }
147+
148+ [ Fact ]
149+ public async Task SequenceEqualAsync_Comparer_NotSame_IList ( )
115150 {
116151 var xs = new [ ] { 1 , 2 , 3 } . ToAsyncEnumerable ( ) ;
117152 var ys = new [ ] { 1 , 3 , 2 } . ToAsyncEnumerable ( ) ;
@@ -120,16 +155,16 @@ public async Task SequenceEqual10Async()
120155 }
121156
122157 [ Fact ]
123- public async Task SequenceEqual11Async ( )
158+ public async Task SequenceEqualAsync_Comparer_NotSame_DifferentLength ( )
124159 {
125- var xs = new [ ] { 1 , 2 , 3 , 4 } . ToAsyncEnumerable ( ) ;
126- var ys = new [ ] { 1 , 2 , 3 } . ToAsyncEnumerable ( ) ;
160+ var xs = new [ ] { 1 , 2 , 3 , 4 } . ToAsyncEnumerable ( ) . Select ( x => x ) ;
161+ var ys = new [ ] { 1 , 2 , 3 } . ToAsyncEnumerable ( ) . Select ( x => x ) ;
127162 var res = xs . SequenceEqualAsync ( ys , new Eq ( ) ) ;
128163 Assert . False ( await res ) ;
129164 }
130165
131166 [ Fact ]
132- public async Task SequenceEqual12Async ( )
167+ public async Task SequenceEqualAsync_Comparer_NotSame_DifferentLength_IList ( )
133168 {
134169 var xs = new [ ] { 1 , 2 , 3 } . ToAsyncEnumerable ( ) ;
135170 var ys = new [ ] { 1 , 2 , 3 , 4 } . ToAsyncEnumerable ( ) ;
@@ -138,7 +173,7 @@ public async Task SequenceEqual12Async()
138173 }
139174
140175 [ Fact ]
141- public async Task SequenceEqual13Async ( )
176+ public async Task SequenceEqualAsync_Comparer_Throws_Second ( )
142177 {
143178 var ex = new Exception ( "Bang!" ) ;
144179 var xs = new [ ] { 1 , 2 , 3 , 4 } . ToAsyncEnumerable ( ) ;
@@ -149,7 +184,7 @@ public async Task SequenceEqual13Async()
149184 }
150185
151186 [ Fact ]
152- public async Task SequenceEqual14Async ( )
187+ public async Task SequenceEqualAsync_Comparer_Throws_First ( )
153188 {
154189 var ex = new Exception ( "Bang!" ) ;
155190 var xs = Throw < int > ( ex ) ;
@@ -160,7 +195,7 @@ public async Task SequenceEqual14Async()
160195 }
161196
162197 [ Fact ]
163- public async Task SequenceEqual15Async ( )
198+ public async Task SequenceEqualAsync_Comparer_Same_IList ( )
164199 {
165200 var xs = new [ ] { 1 , 2 , - 3 , 4 } . ToAsyncEnumerable ( ) ;
166201 var ys = new [ ] { 1 , - 2 , 3 , 4 } . ToAsyncEnumerable ( ) ;
@@ -169,15 +204,15 @@ public async Task SequenceEqual15Async()
169204 }
170205
171206 [ Fact ]
172- public async Task SequenceEqual16Async ( )
207+ public async Task SequenceEqualAsync_Comparer_Throws_Equals_IList ( )
173208 {
174209 var xs = new [ ] { 1 , 2 , - 3 , 4 } . ToAsyncEnumerable ( ) ;
175- var ys = new [ ] { 1 , - 2 , 3 , 4 } . ToAsyncEnumerable ( ) ; // NB: Implements IList<T>, resulting in optimized code path.
210+ var ys = new [ ] { 1 , - 2 , 3 , 4 } . ToAsyncEnumerable ( ) ;
176211 await Assert . ThrowsAsync < NotImplementedException > ( ( ) => xs . SequenceEqualAsync ( ys , new EqEx ( ) ) . AsTask ( ) ) ;
177212 }
178213
179214 [ Fact ]
180- public async Task SequenceEqual17Async ( )
215+ public async Task SequenceEqualAsync_Comparer_Throws_Equals ( )
181216 {
182217 var xs = new [ ] { 1 , 2 , - 3 , 4 } . Select ( x => x * 2 ) . ToAsyncEnumerable ( ) ;
183218 var ys = new [ ] { 1 , - 2 , 3 , 4 } . Select ( x => x * 2 ) . ToAsyncEnumerable ( ) ;
@@ -194,7 +229,7 @@ public bool Equals(int x, int y)
194229
195230 public int GetHashCode ( int obj )
196231 {
197- throw new NotImplementedException ( ) ;
232+ throw new NotSupportedException ( ) ;
198233 }
199234 }
200235
0 commit comments