private Chess GetInitiatedGame() { var game = ChessTestHelpers.GetGame(ChessTestHelpers.GetDefaultConfig(player1Id)); game.Join(player1Id, "user"); game.Join(player2Id, "user2"); return(game); }
public void CantResignIfGameNotStarted() { var game = ChessTestHelpers.GetGame(ChessTestHelpers.GetDefaultConfig("1234")); game.Join("1234", "player1"); game.Join("abcd", "player2"); var resignResult = game.Resign("1234"); Assert.False(resignResult.WasSuccessful); }
public void CanRegisterPlayer() { // arrange var game = ChessTestHelpers.GetGame(ChessTestHelpers.GetDefaultConfig("1234")); // act var registrationResult = game.Join("1234", "user"); // assert Assert.True(registrationResult.WasSuccessful, "Failed to register player"); }
public void CanGetPlayer() { // arrange var game = ChessTestHelpers.GetGame(ChessTestHelpers.GetDefaultConfig("1234")); // act game.Join("1234", "user"); var player = game.GetPlayer("1234"); // assert Assert.NotNull(player); }
public void CantRegisterSameNickTwice() { // arrange var game = ChessTestHelpers.GetGame(ChessTestHelpers.GetDefaultConfig("1234")); // act game.Join("1234", "user"); var registrationResult = game.Join("1234", "user"); // assert Assert.False(registrationResult.WasSuccessful, "Was able to register player nick which is already in use"); }
public void GetsCorrectPlayer() { // arrange var game = ChessTestHelpers.GetGame(ChessTestHelpers.GetDefaultConfig("1234")); // act game.Join("1234", "user"); game.Join("abcd", "user2"); var player = game.GetPlayer("1234"); // assert Assert.Equal(player.Id, "1234"); }
public void CantRegisterMoreThanMaxPlayers() { // arrange var game = ChessTestHelpers.GetGame(ChessTestHelpers.GetDefaultConfig("1234")); // act game.Join("1234", "user"); game.Join("abcd", "user2"); var registrationResult = game.Join("zxcv", "user3"); // assert Assert.False(registrationResult.WasSuccessful, "Was able to register player despite game being full"); }
public void CantResignTwice() { var game = ChessTestHelpers.GetGame(ChessTestHelpers.GetDefaultConfig("1234")); game.Join("1234", "player1"); game.Join("abcd", "player2"); game.Start("1234"); var resignResult1 = game.Resign("1234"); var resignResult2 = game.Resign("1234"); Assert.True(resignResult1.WasSuccessful); Assert.False(resignResult2.WasSuccessful); }
public void OnlyHostCanStartGame() { // arrange var game = ChessTestHelpers.GetGame(ChessTestHelpers.GetDefaultConfig("1234")); // act game.Join("1234", "user"); game.Join("abcd", "user2"); var regularPlayerStartResult = game.Start("abcd"); var hostStartResult = game.Start("1234"); // assert Assert.False(regularPlayerStartResult.WasSuccessful, "Non host player was able to start the game"); Assert.True(hostStartResult.WasSuccessful, "Host was unable to start the game"); }
public void CantRegisterPlayerOnceGameHasStarted() { // arrange var game = ChessTestHelpers.GetGame(ChessTestHelpers.GetDefaultConfig("1234")); // act game.Join("1234", "user"); game.Join("abcd", "user2"); game.Start("1234"); var registrationResult = game.Join("zxcv", "user3"); // assert Assert.False(registrationResult.WasSuccessful, "Was able to register player after game has already started"); }
public void SetsHostCorrectly() { // arrange var game = ChessTestHelpers.GetGame(ChessTestHelpers.GetDefaultConfig("1234")); // act game.Join("1234", "user"); game.Join("abcd", "user2"); var playerHost = game.GetPlayer("1234"); var playerNormal = game.GetPlayer("abcd"); // assert Assert.True(playerHost.IsHost, "Not setting host flag to true on host player"); Assert.False(playerNormal.IsHost, "Incorrectly setting host flag to true on normal player"); }
public void CantStartGameWithoutAtleast2Players() { // arrange var game = ChessTestHelpers.GetGame(ChessTestHelpers.GetDefaultConfig("1234")); // act game.Join("1234", "user"); var startGameWithOnePlayerResult = game.Start("1234"); game.Join("abcd", "user2"); var startStartGameWithTwoPlayersResult = game.Start("1234"); // assert Assert.False(startGameWithOnePlayerResult.WasSuccessful, "Was able to start game with only 1 player registered"); Assert.True(startStartGameWithTwoPlayersResult.WasSuccessful, "Was unable to start game with 2 players registered"); }