Skip to content

Commit

Permalink
Use collection expressions in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
atifaziz committed Dec 27, 2024
1 parent 4799c5e commit 86509c9
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion MoreLinq.Test/AcquireTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public void AcquireAll()

Assert.That(disposables.Length, Is.EqualTo(3));

foreach (var disposable in disposables.ZipShortest(new[] { a, b, c }, (act, exp) => new { Actual = act, Expected = exp }))
foreach (var disposable in disposables.ZipShortest([a, b, c], (act, exp) => new { Actual = act, Expected = exp }))
{
Assert.That(disposable.Actual, Is.SameAs(disposable.Expected));
Assert.That(disposable.Actual.Disposed, Is.False);
Expand Down
8 changes: 4 additions & 4 deletions MoreLinq.Test/Async/MergeTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,14 @@ public async Task MergeAsyncAll()
using var ts = TestingSequence.Of(ts1, ts2, ts3, ts4, ts5);
var result = await ts.Merge().ToListAsync();

Assert.That(result, Is.EquivalentTo(new[]
{
Assert.That(result, Is.EquivalentTo(
[
10,
20, 21,
30, 31, 32,
40, 41, 42, 43,
50, 51, 52, 53, 54,
}));
50, 51, 52, 53, 54
]));
}

sealed class AsyncControl<T>
Expand Down
2 changes: 1 addition & 1 deletion MoreLinq.Test/BatchTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ public void BatchUsesCollectionCountAtIterationTime(SourceKind kind)
var result = list.AsSourceKind(kind).Batch(3);

list.Add(3);
result.AssertSequenceEqual(new[] { 1, 2, 3 });
result.AssertSequenceEqual([1, 2, 3]);

list.Add(4);
// should fail trying to enumerate because count is now greater than the batch size
Expand Down
6 changes: 3 additions & 3 deletions MoreLinq.Test/EquiZipTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,23 +48,23 @@ public void BothSequencesDisposedWithUnequalLengthsAndShorterFirst()
[Test]
public void ZipWithEqualLengthSequencesFailStrategy()
{
var zipped = new[] { 1, 2, 3 }.EquiZip(new[] { 4, 5, 6 }, Tuple.Create);
var zipped = new[] { 1, 2, 3 }.EquiZip([4, 5, 6], Tuple.Create);
Assert.That(zipped, Is.Not.Null);
zipped.AssertSequenceEqual((1, 4), (2, 5), (3, 6));
}

[Test]
public void ZipWithFirstSequenceShorterThanSecondFailStrategy()
{
var zipped = new[] { 1, 2 }.EquiZip(new[] { 4, 5, 6 }, Tuple.Create);
var zipped = new[] { 1, 2 }.EquiZip([4, 5, 6], Tuple.Create);
Assert.That(zipped, Is.Not.Null);
Assert.That(zipped.Consume, Throws.InvalidOperationException);
}

[Test]
public void ZipWithFirstSequnceLongerThanSecondFailStrategy()
{
var zipped = new[] { 1, 2, 3 }.EquiZip(new[] { 4, 5 }, Tuple.Create);
var zipped = new[] { 1, 2, 3 }.EquiZip([4, 5], Tuple.Create);
Assert.That(zipped, Is.Not.Null);
Assert.That(zipped.Consume, Throws.InvalidOperationException);
}
Expand Down
6 changes: 3 additions & 3 deletions MoreLinq.Test/TakeLastTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,23 +28,23 @@ public class TakeLastTest
[Test]
public void TakeLast()
{
AssertTakeLast(new[] { 12, 34, 56, 78, 910, 1112 },
AssertTakeLast([12, 34, 56, 78, 910, 1112],
3,
result => result.AssertSequenceEqual(78, 910, 1112));
}

[Test]
public void TakeLastOnSequenceShortOfCount()
{
AssertTakeLast(new[] { 12, 34, 56 },
AssertTakeLast([12, 34, 56],
5,
result => result.AssertSequenceEqual(12, 34, 56));
}

[Test]
public void TakeLastWithNegativeCount()
{
AssertTakeLast(new[] { 12, 34, 56 },
AssertTakeLast([12, 34, 56],
-2,
result => Assert.That(result, Is.Empty));
}
Expand Down
6 changes: 3 additions & 3 deletions MoreLinq.Test/ZipShortestTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,23 +44,23 @@ public void BothSequencesDisposedWithUnequalLengthsAndShorterFirst()
[Test]
public void ZipShortestWithEqualLengthSequences()
{
var zipped = new[] { 1, 2, 3 }.ZipShortest(new[] { 4, 5, 6 }, Tuple.Create);
var zipped = new[] { 1, 2, 3 }.ZipShortest([4, 5, 6], Tuple.Create);
Assert.That(zipped, Is.Not.Null);
zipped.AssertSequenceEqual((1, 4), (2, 5), (3, 6));
}

[Test]
public void ZipShortestWithFirstSequenceShorterThanSecond()
{
var zipped = new[] { 1, 2 }.ZipShortest(new[] { 4, 5, 6 }, Tuple.Create);
var zipped = new[] { 1, 2 }.ZipShortest([4, 5, 6], Tuple.Create);
Assert.That(zipped, Is.Not.Null);
zipped.AssertSequenceEqual((1, 4), (2, 5));
}

[Test]
public void ZipShortestWithFirstSequnceLongerThanSecond()
{
var zipped = new[] { 1, 2, 3 }.ZipShortest(new[] { 4, 5 }, Tuple.Create);
var zipped = new[] { 1, 2, 3 }.ZipShortest([4, 5], Tuple.Create);
Assert.That(zipped, Is.Not.Null);
zipped.AssertSequenceEqual((1, 4), (2, 5));
}
Expand Down

0 comments on commit 86509c9

Please sign in to comment.