public void TestStopClientsRemovedAndStatusChanged() { IGame game = CreateGame("game1", 5, 10); game.Start(new CancellationTokenSource()); CountCallTetriNETCallback callback1 = new CountCallTetriNETCallback(); IClient client1 = CreateClient("client1", callback1); game.Join(client1, true); CountCallTetriNETCallback callback2 = new CountCallTetriNETCallback(); IClient client2 = CreateClient("client2", callback2); game.Join(client2, true); CountCallTetriNETCallback callback3 = new CountCallTetriNETCallback(); IClient client3 = CreateClient("client3", callback3); game.Join(client3, false); game.Stop(); Assert.AreEqual(GameStates.Created, game.State); Assert.AreEqual(0, game.ClientCount); Assert.IsNull(client1.Game); Assert.IsNull(client2.Game); Assert.IsNull(client3.Game); Assert.AreEqual(ClientStates.Connected, client1.State); Assert.AreEqual(ClientStates.Connected, client2.State); Assert.AreEqual(ClientStates.Connected, client3.State); }
public void TestFinishContinuousSpecialActionCallbacksCalled() { IGame game = CreateGame("game1", 5, 10); game.Start(new CancellationTokenSource()); CountCallTetriNETCallback callback1 = new CountCallTetriNETCallback(); IClient client1 = CreateClient("client1", callback1); game.Join(client1, false); CountCallTetriNETCallback callback2 = new CountCallTetriNETCallback(); IClient client2 = CreateClient("client2", callback2); game.Join(client2, false); CountCallTetriNETCallback callback3 = new CountCallTetriNETCallback(); IClient client3 = CreateClient("client3", callback3); game.Join(client3, true); game.StartGame(client1); game.FinishContinuousSpecial(client1, Specials.Darkness); FlushActionQueue(); Assert.AreEqual(0, callback1.GetCallCount("OnContinuousSpecialFinished")); Assert.AreEqual(1, callback2.GetCallCount("OnContinuousSpecialFinished")); Assert.AreEqual(1, callback3.GetCallCount("OnContinuousSpecialFinished")); }
public void TestVoteKickAnswerVoteTargetCannotVote() { IGame game = CreateGame("game1", 5, 10); game.Start(new CancellationTokenSource()); CountCallTetriNETCallback callback1 = new CountCallTetriNETCallback(); IClient client1 = CreateClient("client1", callback1); game.Join(client1, false); CountCallTetriNETCallback callback2 = new CountCallTetriNETCallback(); IClient client2 = CreateClient("client2", callback2); game.Join(client2, false); CountCallTetriNETCallback callback3 = new CountCallTetriNETCallback(); IClient client3 = CreateClient("client3", callback3); game.Join(client3, false); bool succeed = game.VoteKickAnswer(client2, false); Assert.IsFalse(succeed); }
public void TestVoteKickCallbackCalled() { IGame game = CreateGame("game1", 5, 10); game.Start(new CancellationTokenSource()); CountCallTetriNETCallback callback1 = new CountCallTetriNETCallback(); IClient client1 = CreateClient("client1", callback1); game.Join(client1, false); CountCallTetriNETCallback callback2 = new CountCallTetriNETCallback(); IClient client2 = CreateClient("client2", callback2); game.Join(client2, false); CountCallTetriNETCallback callback3 = new CountCallTetriNETCallback(); IClient client3 = CreateClient("client3", callback3); game.Join(client3, false); CountCallTetriNETCallback callback4 = new CountCallTetriNETCallback(); IClient client4 = CreateClient("client4", callback4); game.Join(client4, true); bool succeed = game.VoteKick(client1, client2, "reason"); Assert.IsTrue(succeed); Assert.AreEqual(0, callback1.GetCallCount("OnVoteKickAsked")); // vote initiator automatically answers yes Assert.AreEqual(0, callback2.GetCallCount("OnVoteKickAsked")); // target is not warned Assert.AreEqual(1, callback3.GetCallCount("OnVoteKickAsked")); // other players are asked about vote Assert.AreEqual(0, callback4.GetCallCount("OnVoteKickAsked")); // spectators are not asked about vote }
public void TestVoteKickPropertiesModified() { IGame game = CreateGame("game1", 5, 10); game.Start(new CancellationTokenSource()); CountCallTetriNETCallback callback1 = new CountCallTetriNETCallback(); IClient client1 = CreateClient("client1", callback1); game.Join(client1, false); CountCallTetriNETCallback callback2 = new CountCallTetriNETCallback(); IClient client2 = CreateClient("client2", callback2); game.Join(client2, false); CountCallTetriNETCallback callback3 = new CountCallTetriNETCallback(); IClient client3 = CreateClient("client3", callback3); game.Join(client3, false); bool succeed = game.VoteKick(client1, client2, "reason"); Assert.IsTrue(succeed); Assert.IsNotNull(client1.LastVoteKickAnswer); Assert.IsTrue(client1.LastVoteKickAnswer.Value); }
public void TestLeaveClientCallbackCalled() { IGame game = CreateGame("game1", 5, 10); game.Start(new CancellationTokenSource()); CountCallTetriNETCallback callback1 = new CountCallTetriNETCallback(); IClient client = CreateClient("client1", callback1); game.Join(client, true); game.Leave(client); Assert.AreEqual(1, callback1.GetCallCount("OnGameLeft")); }
public void TestJoinSpectatorOtherClientsInformed() { IGame game = CreateGame("game1", 5, 10); game.Start(new CancellationTokenSource()); CountCallTetriNETCallback callback1 = new CountCallTetriNETCallback(); IClient client1 = CreateClient("client1", callback1); CountCallTetriNETCallback callback2 = new CountCallTetriNETCallback(); IClient client2 = CreateClient("client2", callback2); game.Join(client1, true); game.Join(client2, false); CountCallTetriNETCallback callback3 = new CountCallTetriNETCallback(); IClient client3 = CreateClient("client3", callback3); game.Join(client3, true); Assert.AreEqual(2, callback1.GetCallCount("OnClientGameJoined")); Assert.AreEqual(1, callback2.GetCallCount("OnClientGameJoined")); Assert.AreEqual(0, callback3.GetCallCount("OnClientGameJoined")); Assert.AreEqual(1, callback1.GetCallCount("OnGameMasterModified")); Assert.AreEqual(0, callback2.GetCallCount("OnGameMasterModified")); Assert.AreEqual(0, callback3.GetCallCount("OnGameMasterModified")); }
public void TestClearLinesActionNotEnqueuedIfClassicMultiplayerRulesNotSet() { IGame game = CreateGame("game1", 5, 10); game.Start(new CancellationTokenSource()); CountCallTetriNETCallback callback1 = new CountCallTetriNETCallback(); IClient client1 = CreateClient("client1", callback1); game.Join(client1, false); game.Options.ClassicStyleMultiplayerRules = false; game.StartGame(client1); bool succeed = game.ClearLines(client1, 4); Assert.IsTrue(succeed); Assert.AreEqual(0, ActionQueue.ActionCount); }
public void TestChangeOptionsClientsInformed() { GameOptions originalOptions = new GameOptions(); originalOptions.Initialize(GameRules.Custom); IGame game = CreateGame("game1", 5, 10, GameRules.Custom, originalOptions); game.Start(new CancellationTokenSource()); CountCallTetriNETCallback callback1 = new CountCallTetriNETCallback(); IClient client1 = CreateClient("client1", callback1); game.Join(client1, false); CountCallTetriNETCallback callback2 = new CountCallTetriNETCallback(); IClient client2 = CreateClient("client2", callback2); game.Join(client2, true); CountCallTetriNETCallback callback3 = new CountCallTetriNETCallback(); IClient client3 = CreateClient("client3", callback3); game.Join(client3, false); GameOptions newOptions = new GameOptions(); newOptions.Initialize(GameRules.Custom); game.ChangeOptions(client1, newOptions); Assert.AreEqual(1, callback1.GetCallCount("OnGameOptionsChanged")); Assert.AreEqual(1, callback2.GetCallCount("OnGameOptionsChanged")); Assert.AreEqual(1, callback3.GetCallCount("OnGameOptionsChanged")); }
public void TestResumeGameStatusUpdatedAndCallbacksCalled() { IGame game = CreateGame("game1", 5, 10); game.Start(new CancellationTokenSource()); CountCallTetriNETCallback callback1 = new CountCallTetriNETCallback(); IClient client1 = CreateClient("client1", callback1); game.Join(client1, false); CountCallTetriNETCallback callback2 = new CountCallTetriNETCallback(); IClient client2 = CreateClient("client2", callback2); game.Join(client2, false); CountCallTetriNETCallback callback3 = new CountCallTetriNETCallback(); IClient client3 = CreateClient("client3", callback3); game.Join(client3, true); game.StartGame(client1); game.PauseGame(client1); bool succeed = game.ResumeGame(client1); Assert.IsTrue(succeed); Assert.AreEqual(GameStates.GameStarted, game.State); Assert.AreEqual(1, callback1.GetCallCount("OnGameResumed")); Assert.AreEqual(1, callback2.GetCallCount("OnGameResumed")); Assert.AreEqual(1, callback3.GetCallCount("OnGameResumed")); }
public void TestResumeGameFailedIfGameNotPaused() { IGame game = CreateGame("game1", 5, 10); game.Start(new CancellationTokenSource()); CountCallTetriNETCallback callback1 = new CountCallTetriNETCallback(); IClient client1 = CreateClient("client1", callback1); game.Join(client1, false); CountCallTetriNETCallback callback2 = new CountCallTetriNETCallback(); IClient client2 = CreateClient("client2", callback2); game.Join(client2, false); CountCallTetriNETCallback callback3 = new CountCallTetriNETCallback(); IClient client3 = CreateClient("client3", callback3); game.Join(client3, true); bool succeed = game.ResumeGame(client1); Assert.IsFalse(succeed); Assert.AreEqual(GameStates.WaitStartGame, game.State); Assert.AreEqual(0, callback1.GetCallCount("OnGamePaused")); Assert.AreEqual(0, callback1.GetCallCount("OnGamePaused")); Assert.AreEqual(0, callback1.GetCallCount("OnGamePaused")); }
public void TestStopGameStatusUpdatedAndCallbackCalledIfGameStarted() { IGame game = CreateGame("game1", 5, 10); game.Start(new CancellationTokenSource()); CountCallTetriNETCallback callback1 = new CountCallTetriNETCallback(); IClient client1 = CreateClient("client1", callback1); game.Join(client1, false); CountCallTetriNETCallback callback2 = new CountCallTetriNETCallback(); IClient client2 = CreateClient("client2", callback2); game.Join(client2, true); CountCallTetriNETCallback callback3 = new CountCallTetriNETCallback(); IClient client3 = CreateClient("client3", callback3); game.Join(client3, false); game.StartGame(client1); bool succeed = game.StopGame(client1); Assert.IsTrue(succeed); Assert.AreEqual(GameStates.WaitStartGame, game.State); Assert.AreEqual(1, callback1.GetCallCount("OnGameFinished")); Assert.AreEqual(1, callback2.GetCallCount("OnGameFinished")); Assert.AreEqual(1, callback3.GetCallCount("OnGameFinished")); Assert.AreEqual(ClientStates.WaitInGame, client1.State); Assert.AreEqual(ClientStates.WaitInGame, client2.State); Assert.AreEqual(ClientStates.WaitInGame, client3.State); }
public void TestStartGameFailedIfNotWaitingGameStart() { IGame game = CreateGame("game1", 5, 10); game.Start(new CancellationTokenSource()); CountCallTetriNETCallback callback1 = new CountCallTetriNETCallback(); IClient client1 = CreateClient("client1", callback1); game.Join(client1, false); CountCallTetriNETCallback callback2 = new CountCallTetriNETCallback(); IClient client2 = CreateClient("client2", callback2); game.Join(client2, false); CountCallTetriNETCallback callback3 = new CountCallTetriNETCallback(); IClient client3 = CreateClient("client3", callback3); game.Join(client3, true); game.Stop(); bool succeed = game.StartGame(client1); Assert.IsFalse(succeed); Assert.AreEqual(GameStates.Created, game.State); }
public void TestEarnAchievementCallbacksCalled() { IGame game = CreateGame("game1", 5, 10); game.Start(new CancellationTokenSource()); CountCallTetriNETCallback callback1 = new CountCallTetriNETCallback(); IClient client1 = CreateClient("client1", callback1); game.Join(client1, false); CountCallTetriNETCallback callback2 = new CountCallTetriNETCallback(); IClient client2 = CreateClient("client2", callback2); game.Join(client2, false); CountCallTetriNETCallback callback3 = new CountCallTetriNETCallback(); IClient client3 = CreateClient("client3", callback3); game.Join(client3, true); game.StartGame(client1); game.EarnAchievement(client1, 5, "achievement"); FlushActionQueue(); Assert.AreEqual(0, callback1.GetCallCount("OnAchievementEarned")); Assert.AreEqual(1, callback2.GetCallCount("OnAchievementEarned")); Assert.AreEqual(1, callback3.GetCallCount("OnAchievementEarned")); }
public void TestEarnAchievement() { IGame game = CreateGame("game1", 5, 10); game.Start(new CancellationTokenSource()); CountCallTetriNETCallback callback1 = new CountCallTetriNETCallback(); IClient client1 = CreateClient("client1", callback1); game.Join(client1, false); CountCallTetriNETCallback callback2 = new CountCallTetriNETCallback(); IClient client2 = CreateClient("client2", callback2); game.Join(client2, false); CountCallTetriNETCallback callback3 = new CountCallTetriNETCallback(); IClient client3 = CreateClient("client3", callback3); game.Join(client3, true); game.StartGame(client1); bool succeed = game.EarnAchievement(client1, 5, "achievement"); Assert.IsTrue(succeed); }
public void TestGameLostWithTwoPlayingPlayers() { IGame game = CreateGame("game1", 5, 10); game.Start(new CancellationTokenSource()); CountCallTetriNETCallback callback1 = new CountCallTetriNETCallback(); IClient client1 = CreateClient("client1", callback1); game.Join(client1, false); CountCallTetriNETCallback callback2 = new CountCallTetriNETCallback(); IClient client2 = CreateClient("client2", callback2); game.Join(client2, false); CountCallTetriNETCallback callback3 = new CountCallTetriNETCallback(); IClient client3 = CreateClient("client3", callback3); game.Join(client3, true); game.StartGame(client1); callback1.Reset(); callback2.Reset(); callback3.Reset(); game.GameLost(client2); FlushActionQueue(); Assert.AreEqual(GameStates.WaitStartGame, game.State); Assert.AreEqual(ClientStates.WaitInGame, client1.State); Assert.AreEqual(ClientStates.GameLost, client2.State); Assert.AreEqual(ClientStates.WaitInGame, client3.State); Assert.AreEqual(1, callback1.GetCallCount("OnPlayerLost")); Assert.AreEqual(0, callback2.GetCallCount("OnPlayerLost")); Assert.AreEqual(1, callback3.GetCallCount("OnPlayerLost")); Assert.AreEqual(1, callback1.GetCallCount("OnGameFinished")); Assert.AreEqual(1, callback2.GetCallCount("OnGameFinished")); Assert.AreEqual(1, callback3.GetCallCount("OnGameFinished")); Assert.AreEqual(1, callback1.GetCallCount("OnWinListModified")); Assert.AreEqual(1, callback2.GetCallCount("OnWinListModified")); Assert.AreEqual(1, callback3.GetCallCount("OnWinListModified")); Assert.AreEqual(1, callback1.GetCallCount("OnPlayerWon")); Assert.AreEqual(1, callback2.GetCallCount("OnPlayerWon")); Assert.AreEqual(1, callback3.GetCallCount("OnPlayerWon")); //Assert.AreEqual(client1.Id, callback1.GetCallParameters("OnPlayerWon", 0)[0]); }
public void TestGameLostWithMultiplePlayingPlayer() { IGame game = CreateGame("game1", 5, 10); game.Start(new CancellationTokenSource()); CountCallTetriNETCallback callback1 = new CountCallTetriNETCallback(); IClient client1 = CreateClient("client1", callback1); game.Join(client1, false); CountCallTetriNETCallback callback2 = new CountCallTetriNETCallback(); IClient client2 = CreateClient("client2", callback2); game.Join(client2, false); CountCallTetriNETCallback callback3 = new CountCallTetriNETCallback(); IClient client3 = CreateClient("client3", callback3); game.Join(client3, false); game.StartGame(client1); callback1.Reset(); callback2.Reset(); callback3.Reset(); game.GameLost(client2); FlushActionQueue(); Assert.AreEqual(GameStates.GameStarted, game.State); Assert.AreEqual(ClientStates.Playing, client1.State); Assert.AreEqual(ClientStates.GameLost, client2.State); Assert.AreEqual(ClientStates.Playing, client3.State); Assert.AreEqual(1, callback1.GetCallCount("OnPlayerLost")); Assert.AreEqual(0, callback2.GetCallCount("OnPlayerLost")); Assert.AreEqual(1, callback3.GetCallCount("OnPlayerLost")); }
public void TestJoinSameClient() { IGame game = CreateGame("game1", 5, 10); game.Start(new CancellationTokenSource()); CountCallTetriNETCallback callback1 = new CountCallTetriNETCallback(); IClient client1 = CreateClient("client1", callback1); game.Join(client1, true); bool succeed = game.Join(client1, false); Assert.IsFalse(succeed); }
public void TestJoinSpectatorCallbackCalled() { IGame game = CreateGame("game1", 5, 10); game.Start(new CancellationTokenSource()); CountCallTetriNETCallback callback = new CountCallTetriNETCallback(); IClient client = CreateClient("client1", callback); game.Join(client, true); Assert.AreEqual(1, callback.GetCallCount("OnGameJoined")); }
public void TestResetWinListFailedIfNotInGame() { IGame game = CreateGame("game1", 5, 10); game.Start(new CancellationTokenSource()); CountCallTetriNETCallback callback1 = new CountCallTetriNETCallback(); IClient client1 = CreateClient("client1", callback1); bool succeed = game.ResetWinList(client1); Assert.IsFalse(succeed); }
public void TestLeavePlayerChangeGameMaster() { IGame game = CreateGame("game1", 5, 10); game.Start(new CancellationTokenSource()); CountCallTetriNETCallback callback1 = new CountCallTetriNETCallback(); IClient client1 = CreateClient("client1", callback1); CountCallTetriNETCallback callback2 = new CountCallTetriNETCallback(); IClient client2 = CreateClient("client2", callback2); CountCallTetriNETCallback callback3 = new CountCallTetriNETCallback(); IClient client3 = CreateClient("client3", callback3); game.Join(client1, false); game.Join(client2, false); game.Join(client3, true); bool succeed = game.Leave(client1); Assert.IsTrue(succeed); Assert.AreEqual(2, game.ClientCount); Assert.AreEqual(1, game.PlayerCount); Assert.AreEqual(1, game.SpectatorCount); Assert.AreEqual(client2, game.Clients.First()); Assert.IsFalse(client1.IsGameMaster); Assert.IsTrue(client2.IsGameMaster); Assert.AreEqual(0, callback1.GetCallCount("OnGameMasterModified")); Assert.AreEqual(1, callback2.GetCallCount("OnGameMasterModified")); Assert.AreEqual(1, callback3.GetCallCount("OnGameMasterModified")); }
public void TestResetWinListClientsInformed() { IGame game = CreateGame("game1", 5, 10); game.Start(new CancellationTokenSource()); CountCallTetriNETCallback callback1 = new CountCallTetriNETCallback(); IClient client1 = CreateClient("client1", callback1); game.Join(client1, false); CountCallTetriNETCallback callback2 = new CountCallTetriNETCallback(); IClient client2 = CreateClient("client2", callback2); game.Join(client2, false); CountCallTetriNETCallback callback3 = new CountCallTetriNETCallback(); IClient client3 = CreateClient("client3", callback3); game.Join(client3, false); game.ResetWinList(client1); Assert.AreEqual(1, callback1.GetCallCount("OnWinListModified")); Assert.AreEqual(1, callback2.GetCallCount("OnWinListModified")); Assert.AreEqual(1, callback3.GetCallCount("OnWinListModified")); }
public void TestLeaveClientOtherClientsInformed() { IGame game = CreateGame("game1", 5, 10); game.Start(new CancellationTokenSource()); CountCallTetriNETCallback callback1 = new CountCallTetriNETCallback(); IClient client1 = CreateClient("client1", callback1); game.Join(client1, true); CountCallTetriNETCallback callback2 = new CountCallTetriNETCallback(); IClient client2 = CreateClient("client2", callback2); game.Join(client2, true); CountCallTetriNETCallback callback3 = new CountCallTetriNETCallback(); IClient client3 = CreateClient("client3", callback3); game.Join(client3, false); game.Leave(client1); Assert.AreEqual(1, callback2.GetCallCount("OnClientGameLeft")); Assert.AreEqual(1, callback3.GetCallCount("OnClientGameLeft")); }
public void TestResetWinListFailedIfNotWaitingGameStart() { IGame game = CreateGame("game1", 5, 10); game.Start(new CancellationTokenSource()); CountCallTetriNETCallback callback1 = new CountCallTetriNETCallback(); IClient client1 = CreateClient("client1", callback1); game.Join(client1, false); CountCallTetriNETCallback callback2 = new CountCallTetriNETCallback(); IClient client2 = CreateClient("client2", callback2); game.Join(client2, false); CountCallTetriNETCallback callback3 = new CountCallTetriNETCallback(); IClient client3 = CreateClient("client3", callback3); game.Join(client3, false); game.StartGame(client1); bool succeed = game.ResetWinList(client1); Assert.AreEqual(0, callback1.GetCallCount("OnWinListModified")); Assert.IsFalse(succeed); }
public void TestJoinSpectatorWhileGameStarted() { IGame game = CreateGame("game1", 5, 10); game.Start(new CancellationTokenSource()); CountCallTetriNETCallback callback1 = new CountCallTetriNETCallback(); IClient client1 = CreateClient("client1", callback1); game.Join(client1, false); CountCallTetriNETCallback callback2 = new CountCallTetriNETCallback(); IClient client2 = CreateClient("client2", callback2); game.Join(client2, false); CountCallTetriNETCallback callback3 = new CountCallTetriNETCallback(); IClient client3 = CreateClient("client3", callback3); game.Join(client3, true); game.StartGame(client1); callback1.Reset(); callback2.Reset(); callback3.Reset(); CountCallTetriNETCallback callback4 = new CountCallTetriNETCallback(); IClient client4 = CreateClient("client4", callback4); game.Join(client4, true); Assert.AreEqual(ClientStates.WaitInGame, client4.State); Assert.AreEqual(ClientRoles.Spectator, client4.Roles); Assert.AreEqual(1, callback1.GetCallCount("OnClientGameJoined")); Assert.AreEqual(1, callback2.GetCallCount("OnClientGameJoined")); Assert.AreEqual(1, callback3.GetCallCount("OnClientGameJoined")); Assert.AreEqual(1, callback4.GetCallCount("OnGameJoined")); }
public void TestLeavePlayingPlayerWhileGameStartedMultiplePlayingPlayerLeft() { IGame game = CreateGame("game1", 5, 10); game.Start(new CancellationTokenSource()); CountCallTetriNETCallback callback1 = new CountCallTetriNETCallback(); IClient client1 = CreateClient("client1", callback1); game.Join(client1, false); CountCallTetriNETCallback callback2 = new CountCallTetriNETCallback(); IClient client2 = CreateClient("client2", callback2); game.Join(client2, false); CountCallTetriNETCallback callback3 = new CountCallTetriNETCallback(); IClient client3 = CreateClient("client3", callback3); game.Join(client3, false); game.StartGame(client1); callback1.Reset(); callback2.Reset(); callback3.Reset(); game.Leave(client2); Assert.AreEqual(GameStates.GameStarted, game.State); Assert.AreEqual(ClientStates.Playing, client1.State); Assert.AreEqual(ClientStates.Playing, client3.State); Assert.AreEqual(0, callback1.GetCallCount("OnGameFinished")); Assert.AreEqual(0, callback2.GetCallCount("OnGameFinished")); Assert.AreEqual(0, callback3.GetCallCount("OnGameFinished")); Assert.AreEqual(0, callback1.GetCallCount("OnWinListModified")); Assert.AreEqual(0, callback2.GetCallCount("OnWinListModified")); Assert.AreEqual(0, callback3.GetCallCount("OnWinListModified")); }
public void TestVoteKickTimeout() { IGame game = CreateGame("game1", 5, 10); game.Start(new CancellationTokenSource()); CountCallTetriNETCallback callback1 = new CountCallTetriNETCallback(); IClient client1 = CreateClient("client1", callback1); game.Join(client1, false); CountCallTetriNETCallback callback2 = new CountCallTetriNETCallback(); IClient client2 = CreateClient("client2", callback2); game.Join(client2, false); CountCallTetriNETCallback callback3 = new CountCallTetriNETCallback(); IClient client3 = CreateClient("client3", callback3); game.Join(client3, false); game.VoteKick(client1, client2, "reason"); Thread.Sleep(10500); Assert.IsNull(client1.LastVoteKickAnswer); Assert.IsNull(client2.LastVoteKickAnswer); Assert.IsNull(client3.LastVoteKickAnswer); Assert.AreEqual(0, callback1.GetCallCount("OnClientGameLeft")); Assert.AreEqual(0, callback2.GetCallCount("OnGameLeft")); Assert.AreEqual(0, callback3.GetCallCount("OnClientGameLeft")); }
public void TestGameLostWithOnePlayingPlayer() { IGame game = CreateGame("game1", 5, 10); game.Start(new CancellationTokenSource()); CountCallTetriNETCallback callback1 = new CountCallTetriNETCallback(); IClient client1 = CreateClient("client1", callback1); game.Join(client1, false); game.StartGame(client1); callback1.Reset(); game.GameLost(client1); FlushActionQueue(); Assert.AreEqual(GameStates.WaitStartGame, game.State); Assert.AreEqual(ClientStates.GameLost, client1.State); Assert.AreEqual(0, callback1.GetCallCount("OnPlayerLost")); Assert.AreEqual(1, callback1.GetCallCount("OnGameFinished")); Assert.AreEqual(0, callback1.GetCallCount("OnWinListModified")); }
public void TestVoteKickAnswerNoMultipleAnswerForSamePlayer() { IGame game = CreateGame("game1", 5, 10); game.Start(new CancellationTokenSource()); CountCallTetriNETCallback callback1 = new CountCallTetriNETCallback(); IClient client1 = CreateClient("client1", callback1); game.Join(client1, false); CountCallTetriNETCallback callback2 = new CountCallTetriNETCallback(); IClient client2 = CreateClient("client2", callback2); game.Join(client2, false); CountCallTetriNETCallback callback3 = new CountCallTetriNETCallback(); IClient client3 = CreateClient("client3", callback3); game.Join(client3, false); CountCallTetriNETCallback callback4 = new CountCallTetriNETCallback(); IClient client4 = CreateClient("client4", callback4); game.Join(client4, false); game.VoteKick(client1, client2, "reason"); game.VoteKickAnswer(client3, false); bool succeed = game.VoteKickAnswer(client3, false); Assert.IsFalse(succeed); }
public void TestFinishContinuousSpecialOkIfGameStarted() { IGame game = CreateGame("game1", 5, 10); game.Start(new CancellationTokenSource()); CountCallTetriNETCallback callback1 = new CountCallTetriNETCallback(); IClient client1 = CreateClient("client1", callback1); game.Join(client1, false); game.StartGame(client1); bool succeed = game.FinishContinuousSpecial(client1, Specials.Darkness); Assert.IsTrue(succeed); }