本文整理汇总了C#中Game.PlayCard方法的典型用法代码示例。如果您正苦于以下问题:C# Game.PlayCard方法的具体用法?C# Game.PlayCard怎么用?C# Game.PlayCard使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Game
的用法示例。
在下文中一共展示了Game.PlayCard方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PlayCard_throws_InvalidOperationException_when_user_does_not_have_card
public void PlayCard_throws_InvalidOperationException_when_user_does_not_have_card()
{
// Arrange.
const int seed = 42;
var userId = Guid.NewGuid();
var card = new Card(Suit.Hearts, Rank.King);
var sut = new Game().Initialize(Guid.NewGuid(), 2)
.AddUser(Guid.NewGuid())
.AddUser(userId)
.Start(seed);
// Act.
TestDelegate test = () => sut.PlayCard(userId, 2, 5, card);
// Assert.
Assert.That(test, Throws.InvalidOperationException.With.Message.EqualTo("User does not have that card."));
}
示例2: PlayCard_throws_InvalidOperationException_when_user_is_not_in_game
public void PlayCard_throws_InvalidOperationException_when_user_is_not_in_game()
{
// Arrange.
var sut = new Game().Initialize(Guid.NewGuid(), 2)
.AddUser(Guid.NewGuid())
.AddUser(Guid.NewGuid());
// Act.
TestDelegate test = () => sut.PlayCard(Guid.NewGuid(), 1, 1, Card.Empty);
// Assert.
Assert.That(test, Throws.InvalidOperationException);
}
示例3: PlayCard_throws_InvalidOperationException_when_trying_to_remove_nonexisting_chip
public void PlayCard_throws_InvalidOperationException_when_trying_to_remove_nonexisting_chip()
{
// Arrange.
var userId = Guid.NewGuid();
var jack = new Card(Suit.Spades, Rank.Jack);
var sut = new Game().Initialize(Guid.NewGuid(), 2)
.AddUser(Guid.NewGuid())
.AddUser(userId)
.Start(1);
// Act.
TestDelegate test = () => sut.PlayCard(userId, 1, 1, jack);
// Assert.
Assert.That(test, Throws.InvalidOperationException.With.Message.EqualTo("Tile is empty."));
}
示例4: PlayCard_throws_InvalidOperationException_when_coordinate_is_shared
public void PlayCard_throws_InvalidOperationException_when_coordinate_is_shared()
{
// Arrange.
var sut = new Game().Initialize(Guid.NewGuid(), 2)
.AddUser(Guid.NewGuid())
.AddUser(Guid.NewGuid());
// Act.
TestDelegate test = () => sut.PlayCard(sut.Users[0], 0, 0, Card.Empty);
// Assert.
Assert.That(test, Throws.InvalidOperationException);
}
示例5: PlayCard_throws_InvalidOperationException_when_coordinate_is_part_of_a_sequence
public void PlayCard_throws_InvalidOperationException_when_coordinate_is_part_of_a_sequence()
{
// Arrange.
const int seed = 42;
var user1 = Guid.NewGuid();
var user2 = Guid.NewGuid();
var card = new Card(Suit.Hearts, Rank.King);
var sequence = new Sequence(1, 1, 5, SequenceDirection.Horizontal, Team.B);
var sequences = new List<Sequence> { sequence }.AsReadOnly();
var boardMock = new Mock<IGameBoard>();
boardMock.Setup(gb => gb.GetSequences())
.Returns(sequences);
var sut = new Game(_deck, boardMock.Object).Initialize(Guid.NewGuid(), 2)
.AddUser(user1)
.AddUser(user2)
.Start(seed);
// Act.
TestDelegate test = () => sut.PlayCard(user2, 1, 1, card);
// Assert.
Assert.That(test, Throws.InvalidOperationException);
}
示例6: PlayCard_throws_InvalidOperationException_when_card_does_not_match_tile
public void PlayCard_throws_InvalidOperationException_when_card_does_not_match_tile()
{
// Arrange.
const int seed = 42;
const int row = 1;
const int column = 1;
var userId = Guid.NewGuid();
var card = new Card(Suit.Hearts, Rank.King);
var sut = new Game().Initialize(Guid.NewGuid(), 2)
.AddUser(Guid.NewGuid())
.AddUser(userId)
.Start(seed);
// Act.
TestDelegate test = () => sut.PlayCard(userId, row, column, card);
// Assert.
Assert.That(GameBoard.GetCard(row, column), Is.Not.EqualTo(card));
Assert.That(test, Throws.InvalidOperationException.With.Message.EqualTo("Card does not match tile."));
}
示例7: PlayCard_throws_ArgumentNullException_when_card_is_null
public void PlayCard_throws_ArgumentNullException_when_card_is_null()
{
// Arrange.
var userId = Guid.NewGuid();
var sut = new Game().Initialize(Guid.NewGuid(), 2)
.AddUser(Guid.NewGuid())
.AddUser(userId)
.Start();
// Act.
TestDelegate test = () => sut.PlayCard(userId, 1, 1, null);
// Assert.
Assert.That(test, Throws.TypeOf<ArgumentNullException>());
}