public void TestStartGame() { // Arrange var conf = new MockGameConfiguration(); var queue = new BufferBlock <Message>(); var lifetime = Mock.Of <IApplicationLifetime>(); var client = new TcpSocketClient <Message, Message>(logger); var gameMaster = new GM(lifetime, conf, queue, client, logger); var players = gameMaster.GetValue <GM, Dictionary <int, GMPlayer> >("players"); for (int idRed = 0; idRed < conf.NumberOfPlayersPerTeam; ++idRed) { var player = new GMPlayer(idRed, conf, client, Team.Red, logger); players.Add(idRed, player); int idBlue = idRed + conf.NumberOfPlayersPerTeam; player = new GMPlayer(idBlue, conf, client, Team.Blue, logger); players.Add(idBlue, player); } gameMaster.Invoke("InitGame"); // Act var task = gameMaster.Invoke <GM, Task>("StartGame", CancellationToken.None); task.Wait(); // Assert Assert.True(gameMaster.WasGameStarted); // TODO create mock of socket and check if GM sends messages }
public bool MoveHere(GMPlayer player) { if (whosHere == null && player != null) { player.Position = this; whosHere = player; return(true); } return(false); }
public override bool PickUp(GMPlayer player) { if (this.ContainsPieces()) { var piece = Pieces.First(); player.Holding = piece; Pieces.Remove(piece); return(true); } return(false); }
public void PickUpTaskTest(int numPut, int numPick, bool expected) { // Arrange var conf = Mock.Of <GameConfiguration>(); var socketClient = new TcpSocketClient <Message, Message>(logger); GMPlayer gmPlayer = new GMPlayer(1, conf, socketClient, Shared.Enums.Team.Red, logger); TaskField taskField = new TaskField(2, 2); for (int i = 0; i < numPut; i++) { taskField.Put(new NormalPiece()); } bool result = false; // Act for (int i = 0; i < numPick; i++) { result = taskField.PickUp(gmPlayer); } // Assert Assert.Equal(expected, result); }
public override bool PickUp(GMPlayer player) { return(false); }
public abstract bool PickUp(GMPlayer player);
public void Leave(GMPlayer player) { whosHere = null; }