22// The .NET Foundation licenses this file to you under the MIT license.
33
44using System . Collections . Generic ;
5+ using System . Diagnostics ;
56using Xunit ;
67
78namespace System . Linq . Tests
@@ -189,8 +190,9 @@ public void FollowingVariousOperators()
189190 Assert . True ( transform ( source . Concat ( source ) ) . Distinct ( ) . Contains ( 2 ) ) ;
190191 Assert . False ( transform ( source . Concat ( source ) ) . Distinct ( ) . Contains ( 4 ) ) ;
191192 Assert . True ( transform ( source . Concat ( source ) ) . Distinct ( ) . Contains ( 1 ) ) ;
192- Assert . True ( transform ( source . Concat ( source ) ) . Distinct ( EqualityComparer < int > . Create ( ( x , y ) => true ) ) . Contains ( 2 ) ) ;
193- Assert . False ( transform ( source . Concat ( source ) ) . Distinct ( EqualityComparer < int > . Create ( ( x , y ) => true ) ) . Contains ( 0 ) ) ;
193+ Assert . True ( transform ( source . Concat ( source ) ) . Distinct ( EqualityComparer < int > . Create ( ( x , y ) => true , x => 0 ) ) . Contains ( 1 ) ) ;
194+ Assert . False ( transform ( source . Concat ( source ) ) . Distinct ( EqualityComparer < int > . Create ( ( x , y ) => true , x => 0 ) ) . Contains ( 2 ) ) ;
195+ Assert . False ( transform ( source . Concat ( source ) ) . Distinct ( EqualityComparer < int > . Create ( ( x , y ) => true , x => 0 ) ) . Contains ( 0 ) ) ;
194196
195197 // OrderBy
196198 Assert . True ( transformedSource . OrderBy ( x => x ) . Contains ( 2 ) ) ;
@@ -246,13 +248,21 @@ public void FollowingVariousOperators()
246248
247249 // Union
248250 Assert . True ( transformedSource . Union ( transform ( [ 4 ] ) ) . Contains ( 4 ) ) ;
251+ Assert . True ( transformedSource . Union ( transform ( [ 4 ] ) , EqualityComparer < int > . Create ( ( x , y ) => true , x => 0 ) ) . Contains ( 1 ) ) ;
252+ Assert . False ( transformedSource . Union ( transform ( [ 4 ] ) , EqualityComparer < int > . Create ( ( x , y ) => true , x => 0 ) ) . Contains ( 4 ) ) ;
249253 Assert . False ( transformedSource . Union ( transform ( [ 3 ] ) ) . Contains ( 4 ) ) ;
250254 }
251255
252256 // DefaultIfEmpty
253257 Assert . True ( Enumerable . Empty < int > ( ) . DefaultIfEmpty ( 1 ) . Contains ( 1 ) ) ;
254258 Assert . False ( Enumerable . Empty < int > ( ) . DefaultIfEmpty ( 1 ) . Contains ( 0 ) ) ;
255259
260+ // Distinct
261+ Assert . True ( new string [ ] { "a" , "A" } . Distinct ( ) . Contains ( "a" ) ) ;
262+ Assert . True ( new string [ ] { "a" , "A" } . Distinct ( ) . Contains ( "A" ) ) ;
263+ Assert . True ( new string [ ] { "a" , "A" } . Distinct ( StringComparer . OrdinalIgnoreCase ) . Contains ( "a" ) ) ;
264+ Assert . False ( new string [ ] { "a" , "A" } . Distinct ( StringComparer . OrdinalIgnoreCase ) . Contains ( "A" ) ) ;
265+
256266 // Repeat
257267 Assert . True ( Enumerable . Repeat ( 1 , 5 ) . Contains ( 1 ) ) ;
258268 Assert . False ( Enumerable . Repeat ( 1 , 5 ) . Contains ( 2 ) ) ;
@@ -268,6 +278,12 @@ public void FollowingVariousOperators()
268278 Assert . False ( new object [ ] { 1 , "2" , 3 } . OfType < int > ( ) . Contains ( 2 ) ) ;
269279 Assert . True ( new object [ ] { 1 , "2" , 3 } . OfType < string > ( ) . Contains ( "2" ) ) ;
270280 Assert . False ( new object [ ] { 1 , "2" , 3 } . OfType < string > ( ) . Contains ( "4" ) ) ;
281+
282+ // Union
283+ Assert . True ( new string [ ] { "a" } . Union ( new string [ ] { "A" } ) . Contains ( "a" ) ) ;
284+ Assert . True ( new string [ ] { "a" } . Union ( new string [ ] { "A" } ) . Contains ( "A" ) ) ;
285+ Assert . True ( new string [ ] { "a" } . Union ( new string [ ] { "A" } , StringComparer . OrdinalIgnoreCase ) . Contains ( "a" ) ) ;
286+ Assert . False ( new string [ ] { "a" } . Union ( new string [ ] { "A" } , StringComparer . OrdinalIgnoreCase ) . Contains ( "A" ) ) ;
271287 }
272288 }
273289}
0 commit comments