//[TestMethod] public void KeepAliveFromGameMasterDoesNotInteractWithNormalMessages() { CommunicationServer.Connection server = new CommunicationServer.Connection(8004); server.StartServer(); GameMaster.Connection gameMaster = new GameMaster.Connection(IPADDRESS, PORT + 4, parameters); gameMaster.Connect(); Thread.Sleep(1500); var gameMessage = new Xsd2.RegisterGame(new Xsd2.GameInfo() { gameName = gameName, redTeamPlayers = 1, blueTeamPlayers = 1 }); var xmlSerializer = new XmlSerializer(typeof(Xsd2.RegisterGame)); using (var writer = new StringWriter()) { xmlSerializer.Serialize(writer, gameMessage); gameMaster.SendMessage(writer.ToString()); } Thread.Sleep(SLEEPTIME); // Checks if IsGameMaster property is set to true Assert.AreEqual(true, server.Receivers[0].IsGameMaster); gameMaster.Disconnect(); server.StopServer(); Task.WaitAll(); }
//[TestMethod] // TO FIX public void GameMasterDoesntStartGame() { CommunicationServer.Connection serv = new CommunicationServer.Connection(8004); serv.StartServer(); GameMaster.Connection gameMaster = new GameMaster.Connection(IPADDRESS, PORT + 4, parameters); gameMaster.Connect(); Thread.Sleep(SLEEPTIME); // Checks if IsGameMaster property is set to false Assert.AreEqual(false, serv.Receivers[0].IsGameMaster); var gameMessage = new Xsd2.RegisterGame(); var xmlSerializer = new XmlSerializer(typeof(Xsd2.RegisterGame)); using (var writer = new StringWriter()) { xmlSerializer.Serialize(writer, gameMessage); gameMaster.SendMessage(writer.ToString()); } Thread.Sleep(SLEEPTIME); // Checks if IsGameMaster property is set to true Assert.AreEqual(true, serv.Receivers[0].IsGameMaster); gameMaster.Disconnect(); serv.StopServer(); Task.WaitAll(); }
public void CommunicationServerReceivesKeepAliveMessageFromGameMaster() { CommunicationServer.Connection server = new CommunicationServer.Connection(8004); server.StartServer(); GameMaster.Connection gameMaster = new GameMaster.Connection(IPADDRESS, PORT + 4, parameters); gameMaster.Connect(); Thread.Sleep(4 * SLEEPTIME); Assert.AreEqual(1, server.Receivers.Count); gameMaster.Disconnect(); server.StopServer(); Task.WaitAll(); }
public void ChecksIfGameMasterCanConnectToCommunicationServer() { CommunicationServer.Connection serv = new CommunicationServer.Connection(PORT); serv.StartServer(); GameMaster.Connection gameMaster = new GameMaster.Connection(IPADDRESS, PORT, parameters); gameMaster.Connect(); Thread.Sleep(SLEEPTIME); // Checking if gamemaster connected Assert.AreEqual(1, serv.Receivers.Count); gameMaster.Disconnect(); Thread.Sleep(SLEEPTIME); serv.StopServer(); Thread.Sleep(SLEEPTIME); Task.WaitAll(); }
public void ChecksIfPlayerAndGameMasterCanConnectToCommunicationServer() { CommunicationServer.Connection serv = new CommunicationServer.Connection(PORT + 1); serv.StartServer(); GameMaster.Connection gameMaster = new GameMaster.Connection(IPADDRESS, PORT + 1, parameters); gameMaster.Connect(); var gameMessage = new Xsd2.RegisterGame(new Xsd2.GameInfo() { redTeamPlayers = 1, blueTeamPlayers = 1, gameName = gameName }); var xmlSerializer = new XmlSerializer(typeof(Xsd2.RegisterGame)); using (var writer = new StringWriter()) { xmlSerializer.Serialize(writer, gameMessage); gameMaster.SendMessage(writer.ToString()); } var player = FakeItEasy.A.Fake <Player.Connection>(o => o.WithArgumentsForConstructor( new object[] { "127.0.0.1", 8001, gameName, playerParameters, new object() })); player.Connect(); Thread.Sleep(SLEEPTIME); int gmCount = 0; foreach (var reciever in serv.Receivers) { if (reciever.IsGameMaster) { gmCount++; } } // Checking if there is only one gamemaster Assert.AreEqual(1, gmCount); // Checking if gamemaster and player properly connected Assert.AreEqual(2, serv.Receivers.Count); player.Disconnect(); Thread.Sleep(SLEEPTIME); gameMaster.Disconnect(); Thread.Sleep(SLEEPTIME); serv.StopServer(); Thread.Sleep(SLEEPTIME); Task.WaitAll(); }