@@ -25,11 +25,13 @@ public sealed class ImmutableArrayComparerTests : EnumerableComparerTests
2525
2626 public sealed class CustomListComparerTests : EnumerableComparerTests
2727 {
28+ #pragma warning disable IDE0028 // Simplify collection initialization -- Want to use custom type
2829 protected override IEnumerable < T > CreateCollectionCore < T > ( IEnumerable < T > elements ) => new CustomList < T > ( elements . ToList ( ) ) ;
30+ #pragma warning restore IDE0028 // Simplify collection initialization
2931
3032 private sealed class CustomList < T > : IList < T >
3133 {
32- private IList < T > WrappedList { get ; } = new List < T > ( ) ;
34+ private IList < T > WrappedList { get ; } = [ ] ;
3335 public T this [ int index ]
3436 {
3537 get => this . WrappedList [ index ] ;
@@ -88,7 +90,7 @@ public sealed class CustomReadOnlyCollectionComparerTests : EnumerableComparerTe
8890
8991 private sealed class CustomReadOnlyCollection < T > : IReadOnlyCollection < T >
9092 {
91- private IList < T > WrappedList { get ; } = new List < T > ( ) ;
93+ private IList < T > WrappedList { get ; } = [ ] ;
9294 public int Count => this . WrappedList . Count ;
9395 public IEnumerator < T > GetEnumerator ( ) => this . WrappedList . GetEnumerator ( ) ;
9496 IEnumerator IEnumerable . GetEnumerator ( ) => this . GetEnumerator ( ) ;
@@ -106,7 +108,7 @@ public sealed class CustomEnumerableComparerTests : EnumerableComparerTests
106108
107109 private sealed class CustomEnumerable < T > : IEnumerable < T >
108110 {
109- private IList < T > WrappedList { get ; } = new List < T > ( ) ;
111+ private IList < T > WrappedList { get ; } = [ ] ;
110112 public IEnumerator < T > GetEnumerator ( ) => this . WrappedList . GetEnumerator ( ) ;
111113 IEnumerator IEnumerable . GetEnumerator ( ) => this . GetEnumerator ( ) ;
112114
@@ -124,7 +126,7 @@ public abstract class EnumerableComparerTests
124126
125127 protected IEnumerable < T > CreateCollection < T > ( T singleElement )
126128 {
127- return this . CreateCollectionCore ( new [ ] { singleElement } ) ;
129+ return this . CreateCollectionCore ( [ singleElement ] ) ;
128130 }
129131
130132 protected virtual IEnumerable < T > ? CreateCollectionWithEqualityComparer < T > ( IEnumerable < T > elements , IComparer < T > comparer )
@@ -258,8 +260,8 @@ public void EnumerableEquals_WithStringIdentities_ShouldReturnExpectedResult(str
258260 [ InlineData ( "A" , "AA" , false ) ]
259261 public void EnumerableEquals_WithStringsAndIgnoreCaseComparer_ShouldReturnExpectedResult ( string ? one , string ? two , bool expectedResult )
260262 {
261- var left = this . CreateCollectionWithEqualityComparer ( new [ ] { one } , StringComparer . OrdinalIgnoreCase ) ;
262- var right = this . CreateCollectionWithEqualityComparer ( new [ ] { two } , StringComparer . OrdinalIgnoreCase ) ;
263+ var left = this . CreateCollectionWithEqualityComparer ( [ one ] , StringComparer . OrdinalIgnoreCase ) ;
264+ var right = this . CreateCollectionWithEqualityComparer ( [ two ] , StringComparer . OrdinalIgnoreCase ) ;
263265
264266 if ( left is null || right is null )
265267 return ; // Implementation does not support custom comparer
@@ -274,8 +276,8 @@ public void EnumerableEquals_WithStringsAndIgnoreCaseComparer_ShouldReturnExpect
274276 [ Fact ]
275277 public void EnumerableEquals_WithoutTwoWayEquality_ShouldReturnExpectedResult ( )
276278 {
277- var left = this . CreateCollectionWithEqualityComparer ( new [ ] { "A" , "a" , } , StringComparer . Ordinal ) ;
278- var right = this . CreateCollectionWithEqualityComparer ( new [ ] { "A" , } , StringComparer . Ordinal ) ;
279+ var left = this . CreateCollectionWithEqualityComparer ( [ "A" , "a" , ] , StringComparer . Ordinal ) ;
280+ var right = this . CreateCollectionWithEqualityComparer ( [ "A" , ] , StringComparer . Ordinal ) ;
279281
280282 if ( left is null || right is null )
281283 return ; // Implementation does not support custom comparer
@@ -290,8 +292,8 @@ public void EnumerableEquals_WithoutTwoWayEquality_ShouldReturnExpectedResult()
290292 [ Fact ]
291293 public void EnumerableEquals_WithIgnoreCaseWithTwoWayEquality_ShouldReturnExpectedResult ( )
292294 {
293- var left = this . CreateCollectionWithEqualityComparer ( new [ ] { "A" , "a" , } , StringComparer . OrdinalIgnoreCase ) ;
294- var right = this . CreateCollectionWithEqualityComparer ( new [ ] { "A" , } , StringComparer . OrdinalIgnoreCase ) ;
295+ var left = this . CreateCollectionWithEqualityComparer ( [ "A" , "a" , ] , StringComparer . OrdinalIgnoreCase ) ;
296+ var right = this . CreateCollectionWithEqualityComparer ( [ "A" , ] , StringComparer . OrdinalIgnoreCase ) ;
295297
296298 if ( left is null || right is null )
297299 return ; // Implementation does not support custom comparer
@@ -304,8 +306,8 @@ public void EnumerableEquals_WithIgnoreCaseWithTwoWayEquality_ShouldReturnExpect
304306 [ Fact ]
305307 public void EnumerableEquals_WithDifferentCaseComparersWithoutTwoWayEquality_ShouldReturnExpectedResult ( )
306308 {
307- var left = this . CreateCollectionWithEqualityComparer ( new [ ] { "a" , } , StringComparer . Ordinal ) ;
308- var right = this . CreateCollectionWithEqualityComparer ( new [ ] { "A" , } , StringComparer . OrdinalIgnoreCase ) ;
309+ var left = this . CreateCollectionWithEqualityComparer ( [ "a" , ] , StringComparer . Ordinal ) ;
310+ var right = this . CreateCollectionWithEqualityComparer ( [ "A" , ] , StringComparer . OrdinalIgnoreCase ) ;
309311
310312 if ( left is null || right is null )
311313 return ; // Implementation does not support custom comparer
@@ -320,8 +322,8 @@ public void EnumerableEquals_WithDifferentCaseComparersWithoutTwoWayEquality_Sho
320322 [ Fact ]
321323 public void EnumerableEquals_WithDifferentCaseComparersWithTwoWayEquality_ShouldReturnExpectedResult ( )
322324 {
323- var left = this . CreateCollectionWithEqualityComparer ( new [ ] { "A" , "a" , } , StringComparer . Ordinal ) ;
324- var right = this . CreateCollectionWithEqualityComparer ( new [ ] { "A" , } , StringComparer . OrdinalIgnoreCase ) ;
325+ var left = this . CreateCollectionWithEqualityComparer ( [ "A" , "a" , ] , StringComparer . Ordinal ) ;
326+ var right = this . CreateCollectionWithEqualityComparer ( [ "A" , ] , StringComparer . OrdinalIgnoreCase ) ;
325327
326328 if ( left is null || right is null )
327329 return ; // Implementation does not support custom comparer
0 commit comments