public override GameObject OnLobbyServerCreateGamePlayer(NetworkConnection conn, short playerControllerId) { foreach (var identity in conn.playerControllers) { GameObject identityGO = identity.gameObject; if (identityGO == null) { continue; } MockPlayer mock = identityGO.GetComponent <MockPlayer>(); if (mock == null) { continue; } mock.UpdateSelection(); GameObject prefab = GetPrefab(mock.playerClass); Transform startPosition = GetStartPosition(); GameObject player = GameObject.Instantiate(prefab); player.transform.position = startPosition.position; return(player); } Debug.LogWarning("Couldn't find mock player on player with connid " + conn.connectionId); return(base.OnLobbyServerCreateGamePlayer(conn, playerControllerId)); }
public void LaunchGame_GameLaunchedAfterJoining_InitialBoardPassedBack() { var mockDice = new MockDiceCreator() .AddExplicitDiceRollSequence(new uint[] { 12, 10, 8, 2 }) .Create(); var player = new MockPlayer(PlayerName); var opponents = new[] { new MockComputerPlayer(FirstOpponentName), new MockComputerPlayer(SecondOpponentName), new MockComputerPlayer(ThirdOpponentName) }; var mockPlayerFactory = LocalGameControllerTestCreator.CreateMockPlayerPool(player, opponents); var localGameController = new LocalGameControllerCreator().ChangeDice(mockDice).ChangePlayerPool(mockPlayerFactory).Create(); GameBoardSetup gameBoardData = null; localGameController.InitialBoardSetupEvent = (GameBoardSetup g) => { gameBoardData = g; }; localGameController.JoinGame(); localGameController.LaunchGame(); gameBoardData.ShouldNotBeNull(); }
public void Test_GetBullet() { var model = new MockRoyalGameModel(); var player = new MockPlayer() { Model = model }; var weapon = new Weapon(model, TypesGameObject.Weapon, TypesBehaveObjects.Active, TypesWeapon.Gun); (weapon as Weapon).Owner = player; Magazin magazin = new Magazin(weapon, TypesWeapon.Gun, 50, 300, 8); magazin.Setup(); //делаем 8 выстрелов for (int i = 0; i < 8; i++) { Assert.IsNotNull(magazin.GetBullet()); Assert.IsNull(magazin.GetBullet()); magazin.Parent.Update(new TimeQuantPassed(51)); } //перезаряжаем Assert.IsNull(magazin.GetBullet()); magazin.Parent.Update(new TimeQuantPassed(301)); Assert.IsNotNull(magazin.GetBullet()); }
public void Test_Handler_GotDamage_100HP() { //Arrange (подготовка) int expectedHP = 0; int DamageHP = 100; MockRoyalGameModel model = new MockRoyalGameModel(); var player = new MockPlayer() { Model = model }; Healthy healthy = new Healthy(player); healthy.Setup(); //Act (выполнение) player.Update_GotDamage(new GotDamage(player.ID, DamageHP)); IMessage msg = model.outgoingMessages.Dequeue(); //Assert (проверка) Assert.IsTrue(player.Destroyed); Assert.IsTrue((msg as ChangedValueHP).HP == expectedHP); Assert.AreEqual(expectedHP, healthy.HP); Assert.AreEqual(0, model.outgoingMessages.Count); }
public void Creates_Human_Context_When_AI_Is_Human() { var ai = new MockHumanIntelligence(); var board = new MockBoard(); var player1 = new MockPlayer { Symbol = 'X' }.GetIntelligenceStubbedToReturn(ai); var player2 = new MockPlayer { Symbol = 'O' }.GetIntelligenceStubbedToReturn(ai); var players = new List <IPlayer> { player1, player2 }; var game = new MockGame { Board = board, CurrentPlayer = player1, Players = players }; var factory = new IntelligenceContextFactory(); var context = factory.Create(game); context.Should().BeOfType <HumanContext>(); var humanContext = (HumanContext)context; humanContext.Board.Should().Be(board); }
public void Creates_MiniMax_Context_When_AI_Is_MiniMax() { var ai = new MiniMaxIntelligence(); var board = new MockBoard(); var player1 = new MockPlayer { Symbol = 'X' }.GetIntelligenceStubbedToReturn(ai); var player2 = new MockPlayer { Symbol = 'O' }.GetIntelligenceStubbedToReturn(ai); var players = new List <IPlayer> { player1, player2 }; var game = new MockGame { Board = board, CurrentPlayer = player1, Players = players }; var factory = new IntelligenceContextFactory(); var context = factory.Create(game); context.Should().BeOfType <MiniMaxContext>(); var minimaxContext = (MiniMaxContext)context; minimaxContext.Board.Should().Be(board); minimaxContext.MinimizedPlayer.Should().Be(player1); minimaxContext.Players.Should().BeEquivalentTo(players); }
public void Handles_Should_Choose_A_Position() { var context = new MockIntelligenceContext(); var currentPlayer = new MockPlayer(); var player = new MockPlayer(); var board = new MockBoard { Size = 3 }; var game = new MockGame { Board = board, Players = new List <IPlayer> { currentPlayer, player }, CurrentPlayer = currentPlayer }.IsOverStubbedToReturn(false); var newContext = new MockIntelligenceContext(); var contextFactory = new MockIntelligenceContextFactory().CreateStubbedToReturn(newContext); var state = BuildPlayer1TurnState(game, contextFactory, context); state.Handle(); game.VerifyMakeMoveCalled(context); game.VerifySwitchPlayerCalled(); contextFactory.VerifyCreatedCalled(game); }
public void AddPlayerToLobbyList(MockPlayer p) { var entry = Instantiate(lobbyPlayerListEntryPrefab, lobbyPlayerListContent); entry.GetComponent <LobbyPlayerListEntryUi>().Player = p; lobbyPlayerDictionary.Add(p, entry); lobbyConnectedPlayerText.text = lobbyPlayerDictionary.Count + " / " + lobby.maxPlayers + " Players"; }
public void RegisterAudioPlayer_Should_AddTheGivenPlayerToTheRegisteredAudioPlayersList() { var mockPlayer = new MockPlayer(); _subject.RegisterAudioPlayer(mockPlayer); _subject.RegisteredAudioPlayers.Should().Contain(mockPlayer); }
public void VideoPlayer_RegisteredVideoPlayersHasOnePlayer_ReturnsThePlayer() { var mockPlayer = new MockPlayer(); _subject.RegisterVideoPlayer(mockPlayer); _subject.VideoPlayer.Should().Be(mockPlayer); }
private void LoadPlayersByIdForCustomAsserts(MockPlayer player, MockComputerPlayer firstOpponent, MockComputerPlayer secondOpponent, MockComputerPlayer thirdOpponent) { this.playersById = new Dictionary <Guid, IPlayer>(); this.playersById.Add(player.Id, player); this.playersById.Add(firstOpponent.Id, firstOpponent); this.playersById.Add(secondOpponent.Id, secondOpponent); this.playersById.Add(thirdOpponent.Id, thirdOpponent); }
public void SetPlayer_ShouldNotSetPlayer() { var player = new MockPlayer(); var tile = BuildEmptyTile(); var actual = tile.SetPlayer(player); Assert.NotEqual(player, actual.Player); }
public void SetUpPiecesTest() { var player = new MockPlayer(); var board = new ChessBoard(); player.SetUpPieces(board); //Should be a MockPiece at a7, ie y=1 and x=0 Assert.IsNotNull(board.Board[1][0].BoardSquareContent); }
public TestInstances(LocalGameController localGameController, MockPlayer player, MockComputerPlayer firstOpponent, MockComputerPlayer secondOpponent, MockComputerPlayer thirdOpponent, MockDice dice) { this.MainPlayer = player; this.FirstOpponent = firstOpponent; this.SecondOpponent = secondOpponent; this.ThirdOpponent = thirdOpponent; this.Dice = dice; this.LocalGameController = localGameController; }
public void SetPlayer_ShouldSetPlayer() { var player = new MockPlayer(); var tile = BuildOccupiedTile(); var actual = tile.SetPlayer(player); Assert.Equal(player, actual.Player); }
public void RemovePlayerFromLobbyList(MockPlayer p) { if (lobbyPlayerDictionary.ContainsKey(p)) { Destroy(lobbyPlayerDictionary[p]); lobbyPlayerDictionary.Remove(p); } lobbyConnectedPlayerText.text = lobbyPlayerDictionary.Count + " / " + lobby.maxPlayers + " Players"; }
public void Add_AddsANewStartingPlayer() { var startingPlayer = new MockStartingPlayer(); var player = new MockPlayer(); var mapper = new StartingPlayerMapper(); var actual = mapper.Add(startingPlayer, player); Assert.Equal(player, actual[startingPlayer]); }
public void RequestActionOnEmptyBoardIsFirstSpotAvailable() { IBoard board = new Board(1, 1); PlayerBase p = new MockPlayer("Hank", 'X', board); IGameAction action = p.RequestAction(); Assert.AreEqual(0, action.Row); Assert.AreEqual(0, action.Column); Assert.AreEqual('X', action.Marker); }
public void HandleStartPlayback_Always_SetsTheCurrentPlayerToThePlayerForTheItem() { var mockPlayer = new MockPlayer(); _subject.DefaultAudioPlayer = mockPlayer; var playlistItem = new PlaylistItem(); _subject.Handle(new StartPlaybackMessage(playlistItem)); _subject.CurrentPlayer.Should().Be(mockPlayer); }
public void RequestActionOnFullBoardIsNull() { IBoard board = new Board(1, 1); PlayerBase p = new MockPlayer("Hank", 'X', board); board.MarkPosition(0, 0, 'O'); IGameAction action = p.RequestAction(); Assert.Null(action); }
public void VideoPlayer_RegisteredVideoPlayersHasTwoPlayersAndNoDefaultVideoPlayer_ReturnsTheFirstPlayer() { var mockPlayer1 = new MockPlayer(); var mockPlayer2 = new MockPlayer(); _subject.RegisterVideoPlayer(mockPlayer1); _subject.RegisterVideoPlayer(mockPlayer2); _subject.DefaultVideoPlayer = null; _subject.VideoPlayer.Should().Be(mockPlayer1); }
public void SetCurrentPlayer_WhenPlayerFound() { var player = new MockPlayer(); var players = new Players(); players.Add(player); var actual = players.SetCurrentPlayer(player); Assert.Equal(player, actual.Current); }
public void Does_Not_Throw_Exception_When_Adding_A_Token_To_An_Unoccupied_Square() { var player = new MockPlayer { Symbol = 'X' }; var board = BuildBoard(); Action action = () => board.SetCoordinate(player, new BoardCoordinate(2, 1)); action.ShouldNotThrow <ArgumentException>(); }
public void GetPlayerFor_ModelHasTypeVideo_ReturnTheVideoPlayer() { var mockPlayer1 = new MockPlayer(); _subject.DefaultAudioPlayer = mockPlayer1; var mockPlayer2 = new MockVideoPlayer(); _subject.DefaultVideoPlayer = mockPlayer2; var player = _subject.GetPlayerFor(new PlaylistItem { Type = PlaylistItemTypeEnum.Video }); player.Should().Be(mockPlayer2); }
public void Next_WhenOnePlayerAndCurrentSetToPlayer_ReturnsOnePlayer() { var player = new MockPlayer(); var players = new Players(); players.Add(player); var actual = players.SetCurrentPlayer(player).Next(); Assert.Equal(player, actual.Current); }
public void Add_AddMultipleWithSameKey_ThrowsArgumentException() { var startingPlayer = new MockStartingPlayer(); var player1 = new MockPlayer(); var player2 = new MockPlayer(); var mapper = new StartingPlayerMapper(); var actual = mapper.Add(startingPlayer, player1); Assert.Throws <ArgumentException>(() => actual.Add(startingPlayer, player2)); }
public void HandleStartPlayback_Always_CallsPlayOnThePlayerForTheModelInTheMessage() { var mockPlayer = new MockPlayer(); _subject.DefaultAudioPlayer = mockPlayer; var playlistItem = new PlaylistItem(); _subject.Handle(new StartPlaybackMessage(playlistItem)); mockPlayer.PlayCount.Should().Be(1); mockPlayer.PlayCallArguments.First().Should().Be(playlistItem); }
public void Throws_Exception_When_BoardCoordinate_Is_Not_Within_Limits(int x, int y, int boardSize) { var player = new MockPlayer { Symbol = 'X' }; var board = BuildBoard(boardSize); Action action = () => board.SetCoordinate(player, new BoardCoordinate(x, y)); action.ShouldThrow <ArgumentException>(); }
private static GameInitializer BuildGameInitializer(IPlayersFactory playersFactory = null, IPatternFactory patternFactory = null, IIntelligenceFactory aiFactory = null) { var player1 = new MockPlayer(); var player2 = new MockPlayer(); playersFactory = playersFactory ?? new MockPlayersFactory().CreateStubbedToReturn(new List <IPlayer> { player1, player2 });; patternFactory = patternFactory ?? new MockPatternFactory(); aiFactory = aiFactory ?? new MockIntelligenceFactory(); return(new GameInitializer(playersFactory, patternFactory, aiFactory)); }
public void plackback_continues_even_if_device_is_idle() { // Given a device var device = new DeviceMock(); var mockPlayer = new MockPlayer(); // When a song is playing and no buttons are pressed for 30 seconds mockPlayer.PlaySong(); // Then the device carrys on playing music Assert.True(mockPlayer.isPlayback); }
public void RegisteredPlayers_Always_ReutrnsBothAudioAndVideoRegisteredPlayers() { var mockPlayer1 = new MockPlayer(); var mockPlayer2 = new MockPlayer(); _subject.RegisterAudioPlayer(mockPlayer1); _subject.RegisterVideoPlayer(mockPlayer2); _subject.RegisteredPlayers.Count().Should().Be(2); _subject.RegisteredPlayers.Should().Contain(mockPlayer1); _subject.RegisteredPlayers.Should().Contain(mockPlayer2); }
public void RegisterVideoPlayer_Should_AddTheGivenPlayerToTheRegisteredVideoPlayersList() { var mockPlayer = new MockPlayer(); _subject.RegisterVideoPlayer(mockPlayer); _subject.RegisteredVideoPlayers.Should().Contain(mockPlayer); }
public void VideoPlayer_RegisteredVideoPlayersHasTwoPlayersAndADefaultVideoPlayerIsSet_ReturnsTheDefaultPlayer() { var mockPlayer1 = new MockPlayer(); var mockPlayer2 = new MockPlayer(); _subject.RegisterVideoPlayer(mockPlayer1); _subject.RegisterVideoPlayer(mockPlayer2); var mockPlayer3 = new MockVideoPlayer(); _subject.DefaultVideoPlayer = mockPlayer3; _subject.VideoPlayer.Should().Be(mockPlayer3); }