DateTime lastDate = new DateTime(2009, 10, 1);
foreach (DueAssigmentViewModel assignment in _dueAssigments)
{
if (assignment.DueDate < lastDate)
{
Assert.Fail("Not Correctly Ordered");
}
lastDate = assignment.DueDate;
}
ような何かが私のテストのいくつかでは
再利用可能。
私のinital考え方は、ここovious問題は、あなたが一般的な値にcompaireカントあるこの
public static bool IsOrderedBy<T, TestType>(this IEnumerable<T> value, TestType initalValue)
{
TestType lastValue = initalValue;
foreach (T enumerable in value)
{
if(enumerable < lastValue)
{
return false;
}
lastValue = value;
}
return true;
}
ました。誰もがこの方法を提案することができます。
乾杯 コリン・
これは意味がありません。アイテムの値がソートキーと異なる可能性があるため、OrderByはデリゲートをとります。 'IsSorted'の場合、' Select'でシミュレートすることができます: 'list.Select(f => f.Name).IsSorted()' –
良い点...私はそれを考えませんでした! –
さて、はい、いつでも.Select()を使用してIsSorted()を呼び出すことができますが、その余分なステップを削除しないのはなぜですか? –