Files
dotnet-runtime/src/libraries/System.Linq.Queryable/tests/ChunkTests.cs
T
Robert Andersson 515bfafb35 Add System.Linq Chunk extension method (#47965)
* Add System.Linq Chunk extension method

Fix #27449

* Use explicit types instead of type inference

* Seperate inner and outer loop

* Rename parameter maxSize to size

* Add missing license header

* Remove Chunk.SpeedOpt.cs

* Add tests to verify Chunk works after mutations

* Add/remove before getting enumerator in tests

* Test content of chunk method for IQueryable<T>
2021-02-10 19:41:59 +00:00

26 lines
715 B
C#

// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using Xunit;
namespace System.Linq.Tests
{
public class ChunkTests : EnumerableBasedTests
{
[Fact]
public void ThrowsOnNullSource()
{
IQueryable<int> source = null;
AssertExtensions.Throws<ArgumentNullException>("source", () => source.Chunk(5));
}
[Fact]
public void Chunk()
{
var chunked = new[] {0, 1, 2}.AsQueryable().Chunk(2);
Assert.Equal(2, chunked.Count());
Assert.Equal(new[] {new[] {0, 1}, new[] {2}}, chunked);
}
}
}