本文整理汇总了C#中Rule.OrderBy方法的典型用法代码示例。如果您正苦于以下问题:C# Rule.OrderBy方法的具体用法?C# Rule.OrderBy怎么用?C# Rule.OrderBy使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Rule
的用法示例。
在下文中一共展示了Rule.OrderBy方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Tamagotchi_Rule_TwentyFiveHours
public void Tamagotchi_Rule_TwentyFiveHours()
{
var rules = new Rule[]
{
new AthleticRule(),
new BordedomRule(),
new CrazinessRule(),
new FatigueRule(),
new HungerRule(),
new IsolationRule(),
new MuchiesRule(),
new SleepDeprivationRule(),
new StarvationRule()
};
rules = rules.OrderBy(r => r.Order).ToArray();
var now = DateTime.UtcNow;
Tamagotchi t1 = new Tamagotchi("test", rules);
var inTheFuture = now + TimeSpan.FromHours(25);
t1.RefreshRules(inTheFuture);
Assert.AreEqual(100, t1.Sleep);
Assert.AreEqual(100, t1.Boredom);
Assert.AreEqual(100, t1.Health);
Assert.AreEqual(100, t1.Hunger);
Assert.IsTrue(t1.HasDied);
Assert.AreEqual(t1.LastAllRulesPassedUtc, inTheFuture);
}
示例2: Tamagotchi_Dead_DoNothing
public void Tamagotchi_Dead_DoNothing()
{
var rules = new Rule[]
{
new AthleticRule(),
new BordedomRule(),
new CrazinessRule(),
new FatigueRule(),
new HungerRule(),
new IsolationRule(),
new MuchiesRule(),
new SleepDeprivationRule(),
new StarvationRule()
};
rules = rules.OrderBy(r => r.Order).ToArray();
Tamagotchi t1 = new Tamagotchi("test", rules);
t1.HasDied = true;
var now = DateTime.UtcNow + TimeSpan.FromHours(2);
Assert.IsFalse(t1.EatAction(now));
Assert.IsFalse(t1.RefreshRules(now));
Assert.AreNotEqual(t1.LastAllRulesPassedUtc, now);
}