From 59818a3f0af9388029d5ffcb24c7171d5783184f Mon Sep 17 00:00:00 2001 From: Atif Aziz Date: Sun, 29 Dec 2024 11:39:24 +0100 Subject: [PATCH] SkipLast --- MoreLinq.Test/SkipLastTest.cs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/MoreLinq.Test/SkipLastTest.cs b/MoreLinq.Test/SkipLastTest.cs index 94187ef75..f2252edce 100644 --- a/MoreLinq.Test/SkipLastTest.cs +++ b/MoreLinq.Test/SkipLastTest.cs @@ -28,9 +28,9 @@ public class SkipLastTest [TestCase(-1)] public void SkipLastWithCountLesserThanOne(int skip) { - var numbers = Enumerable.Range(1, 5); - - Assert.That(numbers.SkipLast(skip), Is.EqualTo(numbers)); + using var numbers = Enumerable.Range(1, 5).AsTestingSequence(); + var result = numbers.SkipLast(skip); + Assert.That(result, Is.EqualTo(numbers)); } [Test] @@ -40,17 +40,20 @@ public void SkipLast() const int skip = 20; var sequence = Enumerable.Range(1, take); - var expectations = sequence.Take(take - skip); - Assert.That(expectations, Is.EqualTo(sequence.SkipLast(skip))); + using var source = sequence.AsTestingSequence(); + var result = source.SkipLast(skip); + Assert.That(expectations, Is.EqualTo(result)); } [TestCase(5)] [TestCase(6)] public void SkipLastWithSequenceShorterThanCount(int skip) { - Assert.That(Enumerable.Range(1, 5).SkipLast(skip), Is.Empty); + using var source = Enumerable.Range(1, 5).AsTestingSequence(); + var result = source.SkipLast(skip); + Assert.That(result, Is.Empty); } [Test]