public void TestConnect() { var scl = new ServerPlayerListener(new NetworkConnectorServer(15005, 15006), npf); // Done setup scl.UpdateConnectedPlayers(); Assert.AreEqual(0, gameState.Players.Count()); Assert.AreEqual(0, scl.Players.Count()); var client1 = new NetworkConnectorClient(); client1.Connect("127.0.0.1", 15005); Thread.Sleep(100); scl.UpdateConnectedPlayers(); Assert.AreEqual(1, gameState.Players.Count()); Assert.AreEqual(1, scl.Players.Count()); var client2 = new NetworkConnectorClient(); client2.Connect("127.0.0.1", 15005); Thread.Sleep(100); scl.UpdateConnectedPlayers(); Assert.AreEqual(2, gameState.Players.Count()); Assert.AreEqual(2, scl.Players.Count()); }
public void TestNetworkedUserInput() { var scl = new ServerPlayerListener(new NetworkConnectorServer(15005, 15006), npf); var client = new NetworkConnectorClient(); client.Connect("127.0.0.1", 15005); var proxy = new ProxyPlayerInputHandler(client.UserInputHandlerTransporter); // Done setup scl.UpdateConnectedPlayers(); proxy.OnSave(); Thread.Sleep(100); scl.Players.First().NetworkPlayerInputForwarder.ForwardReceivedInputs(); inputHandler.Received().OnSave(); }