我希望 NUnit 基于两个属性而不是一个属性来测试列表顺序。
片段代码(工作):
var list = new List<Tuple<string, string>>
{
new Tuple<string, string>("aaaa", "bbbb"),
new Tuple<string, string>("bbbb", "aaaa"),
new Tuple<string, string>("aaaa", "cccc"),
new Tuple<string, string>("cccc", "bbbb")
};
var ordered = list.OrderBy(p => p.Item1).ThenBy(p => p.Item2);
Assert.That(ordered, Is.Ordered.By("Item1"));
片段代码(我想要的 - 不工作):
var list = new List<Tuple<string, string>>
{
new Tuple<string, string>("aaaa", "bbbb"),
new Tuple<string, string>("bbbb", "aaaa"),
new Tuple<string, string>("aaaa", "cccc"),
new Tuple<string, string>("cccc", "bbbb")
};
var ordered = list.OrderBy(p => p.Item1).ThenBy(p => p.Item2);
Assert.That(ordered, Is.Ordered.By("Item1").ThenBy("Item2"));
// Below syntax works but does not return expected result
// Assert.That(ordered, Is.Ordered.By("Item1").By("Item2"));