File tree Expand file tree Collapse file tree 2 files changed +22
-3
lines changed Expand file tree Collapse file tree 2 files changed +22
-3
lines changed Original file line number Diff line number Diff line change @@ -3885,6 +3885,28 @@ public void SliceTakeIsNull()
3885
3885
Assert . AreEqual ( expectedList , slicedList ) ;
3886
3886
}
3887
3887
3888
+ [ TestMethod ]
3889
+ public void SliceEmptyEnumerableWithIEnumerableNotCollection ( )
3890
+ {
3891
+ // Test Slice with empty enumerable that's not a collection type
3892
+ // This ensures behavior remains consistent after removing the redundant empty check
3893
+ var rtx = GetNewContext ( ) ;
3894
+ var inputEnumerable = Enumerable . Empty < int > ( ) . Where ( x => true ) ; // Creates IEnumerable<int> not a collection
3895
+ var expectedList = new List < int > ( ) ;
3896
+
3897
+ // Test various slice operations on empty enumerable
3898
+ var slicedList1 = rtx . Operators . Slice ( inputEnumerable , 0 , 5 ) ;
3899
+ var slicedList2 = rtx . Operators . Slice ( inputEnumerable , 2 , null ) ;
3900
+ var slicedList3 = rtx . Operators . Slice ( inputEnumerable , null , null ) ;
3901
+
3902
+ Assert . IsNotNull ( slicedList1 ) ;
3903
+ Assert . IsNotNull ( slicedList2 ) ;
3904
+ Assert . IsNotNull ( slicedList3 ) ;
3905
+ CollectionAssert . AreEqual ( expectedList , slicedList1 . ToList ( ) ) ;
3906
+ CollectionAssert . AreEqual ( expectedList , slicedList2 . ToList ( ) ) ;
3907
+ CollectionAssert . AreEqual ( expectedList , slicedList3 . ToList ( ) ) ;
3908
+ }
3909
+
3888
3910
#endregion
3889
3911
3890
3912
#region ListSkip and ListTake tests
Original file line number Diff line number Diff line change @@ -1048,9 +1048,6 @@ internal partial class CqlOperators
1048
1048
if ( source == null )
1049
1049
return null ;
1050
1050
1051
- if ( ! source . Any ( ) )
1052
- return Enumerable . Empty < T > ( ) ;
1053
-
1054
1051
if ( startIndex == null && endIndex == null )
1055
1052
return source ;
1056
1053
You can’t perform that action at this time.
0 commit comments