本文整理汇总了C#中IPlayer.When方法的典型用法代码示例。如果您正苦于以下问题:C# IPlayer.When方法的具体用法?C# IPlayer.When怎么用?C# IPlayer.When使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IPlayer
的用法示例。
在下文中一共展示了IPlayer.When方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GivenGameRoundIsPlayed_WhenTheplayerWinsOrLosesAMatch_PaysOutAtTheCorrectRate
public void GivenGameRoundIsPlayed_WhenTheplayerWinsOrLosesAMatch_PaysOutAtTheCorrectRate(
DiceValue pick,
DiceValue dieValue1,
DiceValue dieValue2,
DiceValue dieValue3,
int balance,
int bet,
int winnings,
int total,
IDice die1,
IDice die2,
IDice die3,
IPlayer player)
{
// Arrange.
// Set the value of the dice rolled.
die1.CurrentValue.Returns(dieValue1);
die2.CurrentValue.Returns(dieValue2);
die3.CurrentValue.Returns(dieValue3);
die1.roll().Returns(dieValue1);
die2.roll().Returns(dieValue2);
die3.roll().Returns(dieValue3);
// Taking a bet deducts money from the player.
player.When(x => x.takeBet(Arg.Any<int>()));//.Do(x => total -= bet);
var game = new Game(die1, die2, die3);
// Act
var sut = game.PlayRound(player, pick, bet);
// Assert
sut.Should().Be(winnings);
}