Skip to content

Commit

Permalink
Remove no longer needed "AssertMatrix" from "Transpose" tests
Browse files Browse the repository at this point in the history
  • Loading branch information
atifaziz committed Sep 22, 2024
1 parent c6d3c0c commit 0105792
Showing 1 changed file with 4 additions and 17 deletions.
21 changes: 4 additions & 17 deletions MoreLinq.Test/TransposeTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public void TransposeWithRowsOfSameLength()
using var row3 = TestingSequence.Of(30, 31, 32, 33);
using var matrix = TestingSequence.Of(row1, row2, row3);

AssertMatrix(expectations, matrix.Transpose());
Assert.That(matrix.Transpose(), Is.EqualTo(expectations));
}

[Test]
Expand All @@ -77,7 +77,7 @@ public void TransposeWithRowsOfDifferentLengths()
using var row4 = TestingSequence.Of(30, 31, 32);
using var matrix = TestingSequence.Of(row1, row2, row3, row4);

AssertMatrix(expectations, matrix.Transpose());
Assert.That(matrix.Transpose(), Is.EqualTo(expectations));
}

[Test]
Expand Down Expand Up @@ -116,7 +116,7 @@ public void TransposeWithAllRowsAsInfiniteSequences()
[32, 243, 3125]
};

AssertMatrix(expectations, result);
Assert.That(result, Is.EqualTo(expectations));
}

[Test]
Expand All @@ -139,7 +139,7 @@ public void TransposeWithSomeRowsAsInfiniteSequences()
[32, 3125]
};

AssertMatrix(expectations, result);
Assert.That(result, Is.EqualTo(expectations));
}

[Test]
Expand Down Expand Up @@ -207,18 +207,5 @@ static bool IsPrime(int number)

return true;
}

static void AssertMatrix<T>(IEnumerable<IEnumerable<T>> expectation, IEnumerable<IEnumerable<T>> result)
{
// necessary because NUnitLite 3.6.1 (.NET 4.5) for Mono don't assert nested enumerables

var resultList = result.ToList();
var expectationList = expectation.ToList();

Assert.That(resultList.Count, Is.EqualTo(expectationList.Count));

expectationList.Zip(resultList, ValueTuple.Create)
.ForEach(t => t.Item1.AssertSequenceEqual(t.Item2));
}
}
}

0 comments on commit 0105792

Please sign in to comment.