|
17 | 17 |
|
18 | 18 | namespace MoreLinq.Test |
19 | 19 | { |
| 20 | + using System; |
| 21 | + using System.Collections.Generic; |
20 | 22 | using NUnit.Framework; |
| 23 | + using NUnit.Framework.Interfaces; |
21 | 24 | using Tuple = System.ValueTuple; |
22 | 25 |
|
23 | 26 | [TestFixture] |
@@ -76,6 +79,29 @@ public void ZipIsLazy() |
76 | 79 | bs.EquiZip(bs, BreakingFunc.Of<int, int, int>()); |
77 | 80 | } |
78 | 81 |
|
| 82 | + public static readonly IEnumerable<ITestCaseData> TestData = |
| 83 | + from e in new[] |
| 84 | + { |
| 85 | + new { A = 1, B = "First", }, |
| 86 | + new { A = 2, B = "Second", }, |
| 87 | + new { A = 3, B = "Third", }, |
| 88 | + new { A = 4, B = "Fourth", }, |
| 89 | + } |
| 90 | + select new TestCaseData(e.A, e.B); |
| 91 | + |
| 92 | + [Test, TestCaseSource(nameof(TestData))] |
| 93 | + public void ShortestSequenceIsIdentifiedProperly(int shortSequence, string sequenceName) |
| 94 | + { |
| 95 | + using var seq1 = Enumerable.Range(1, shortSequence == 1 ? 2 : 3).AsTestingSequence(); |
| 96 | + using var seq2 = Enumerable.Range(1, shortSequence == 2 ? 2 : 3).AsTestingSequence(); |
| 97 | + using var seq3 = Enumerable.Range(1, shortSequence == 3 ? 2 : 3).AsTestingSequence(); |
| 98 | + using var seq4 = Enumerable.Range(1, shortSequence == 4 ? 2 : 3).AsTestingSequence(); |
| 99 | + |
| 100 | + var ex = Assert.Throws<InvalidOperationException>(() => |
| 101 | + seq1.EquiZip(seq2, seq3, seq4, (_, _, _, _) => 0).Consume()); |
| 102 | + Assert.That(ex.Message, Is.EqualTo(sequenceName + " sequence too short.")); |
| 103 | + } |
| 104 | + |
79 | 105 | [Test] |
80 | 106 | public void MoveNextIsNotCalledUnnecessarily() |
81 | 107 | { |
|
0 commit comments