本文整理汇总了C#中System.Collections.Generic.OrderByDescending方法的典型用法代码示例。如果您正苦于以下问题:C# System.Collections.Generic.OrderByDescending方法的具体用法?C# System.Collections.Generic.OrderByDescending怎么用?C# System.Collections.Generic.OrderByDescending使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Collections.Generic
的用法示例。
在下文中一共展示了System.Collections.Generic.OrderByDescending方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Must_result_in_zero
public void Must_result_in_zero()
{
const string sql = "sql";
IEnumerable<DbParameter> parameters = new[]
{
new SqlParameter("@Test1", 0),
new SqlParameter("@Test2", "Test"),
new SqlParameter("@Test3", 1.45m)
};
var cacheKey1 = new CacheKey(sql, parameters);
var cacheKey2 = new CacheKey(sql, parameters.OrderByDescending(arg => arg.ParameterName));
int result = Comparer<CacheKey>.Default.Compare(cacheKey1, cacheKey2);
Assert.That(result, Is.EqualTo(0));
}
示例2: ShouldDetectTheHighestStraight
public void ShouldDetectTheHighestStraight()
{
var cards = new[] {
3.Of(Suit.Hearts),
4.Of(Suit.Spades),
5.Of(Suit.Clubs),
6.Of(Suit.Diamonds),
7.Of(Suit.Spades),
8.Of(Suit.Clubs),
9.Of(Suit.Hearts)
};
IEnumerable<Card> result = new Straight().Match(cards);
Assert.That( result, Is.EquivalentTo(cards.OrderByDescending( x=>x.Rank).Take(5)), "Should have matched the highest straight.");
}
示例3: ShouldMatchHighestCards
public void ShouldMatchHighestCards()
{
var cards = new[]
{
Picture.Ace.Of(Suit.Clubs), //
Picture.King.Of(Suit.Clubs), //
Picture.Queen.Of(Suit.Clubs), //
Picture.Jack.Of(Suit.Clubs), //
10.Of(Suit.Clubs), //
9.Of(Suit.Clubs),
2.Of(Suit.Hearts)
};
IEnumerable<Card> result = new StraightFlush().Match(cards);
Assert.That( result, Is.EquivalentTo( cards.OrderByDescending( x => x.Rank).Take(5)),
"Should have matched the highest straight flush.");
}
示例4: Test_Order
public void Test_Order()
{
var list = new[]
{
GetApplication(1, "1", 1, "1"),
GetApplication(2, "1", 3, "1"),
GetApplication(3, "1", 5, "0"),
GetApplication(4, "1", 4, "0"),
GetApplication(5, "0", 2, "0")
}.AsQueryable();
var expected = list
.OrderByDescending(x => x.State.Name)
.ThenByDescending(x => x.Id)
.ThenBy(x => x.AirWaybill.Bill).ToArray();
var orders = new[]
{
new Order
{
OrderType = OrderType.State,
Desc = true
},
new Order
{
OrderType = OrderType.Id,
Desc = true
},
new Order
{
OrderType = OrderType.AirWaybill,
Desc = false
}
};
var actual = _orderer.Order(list, orders).ToArray();
for(var i = 0; i < orders.Length; i++)
{
Assert.AreSame(expected[i], actual[i]);
}
}
示例5: ShouldDetectTheHighestFlush
public void ShouldDetectTheHighestFlush()
{
var cards = new[]
{
Picture.Ace.Of(Suit.Spades),
2.Of(Suit.Spades),
3.Of(Suit.Spades),
5.Of(Suit.Spades),
7.Of(Suit.Spades),
9.Of(Suit.Spades),
10.Of(Suit.Spades)
};
IEnumerable<Card> result = new Flush().Match(cards);
Assert.That(result.Count(), Is.EqualTo(5));
Assert.That(result.All(x => x.Suit == Suit.Spades), Is.True, "Should contain the flush only.");
Assert.That(result, Is.EquivalentTo(cards.OrderByDescending(x => x.Rank).Take(5)),
"Should have picked the highest spade cards.");
}