本文整理汇总了C#中Game.Join方法的典型用法代码示例。如果您正苦于以下问题:C# Game.Join方法的具体用法?C# Game.Join怎么用?C# Game.Join使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Game
的用法示例。
在下文中一共展示了Game.Join方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ThrowWhenGameStarted
public void ThrowWhenGameStarted()
{
var game = new Game();
game.Join(PlayerMother.GeneratePlayer());
game.Join(PlayerMother.GeneratePlayer());
game.Start();
Assert.Throws<InvalidGameStateException>(() => game.Join(PlayerMother.GeneratePlayer()));
}
示例2: ThrowWhenGameCompleted
public void ThrowWhenGameCompleted()
{
var game = new Game();
var players = PlayerMother.GeneratePlayers(2);
foreach (var player in players)
game.Join(player);
game.Start();
foreach (var player in players)
game.Move(player, Moves.Paper);
Assert.Throws<InvalidGameStateException>(() => game.Join(PlayerMother.GeneratePlayer()));
}
示例3: AddPlayerToCollection
public void AddPlayerToCollection()
{
//Arrange
var game = new Game();
PlayerRef player = PlayerMother.GeneratePlayer();
//Act
game.Join(player);
//Assert
game.Players.Should().Contain(player);
}
示例4: GenerateStartedGame
public static Game GenerateStartedGame(int numberOfPlayers = 2)
{
var game = new Game()
{
Id = Random.Next()
};
var players = PlayerMother.GeneratePlayers(numberOfPlayers);
foreach (var player in players)
game.Join(player);
game.Start();
DomainEvents.GetEvents().ToArray();
return game;
}
示例5: PublishPlayerJoined
public void PublishPlayerJoined()
{
//Arrange
var game = new Game();
PlayerRef player = PlayerMother.GeneratePlayer();
//Act
game.Join(player);
//Assert
var e = DomainEvents.GetEvents().Single();
e.Should().Be.OfType<PlayerJoined>();
var pje = (PlayerJoined) e;
pje.PlayerId.Should().Be.EqualTo(player.PlayerId);
pje.GameId.Should().Be.EqualTo(game.Id);
}
示例6: ThrowOnNullPlayer
public void ThrowOnNullPlayer()
{
var game = new Game();
Assert.Throws<ArgumentNullException>(() => game.Join(null));
}
示例7: ThrowWhenGameNotStarted
public void ThrowWhenGameNotStarted()
{
var game = new Game();
var players = PlayerMother.GeneratePlayers(2).ToArray();
foreach (var player in players)
game.Join(player);
Assert.Throws<InvalidGameStateException>(() => game.Move(players.First(), Moves.Paper));
}