public void run() { BoggleServer.BoggleServer server = null; BoggleClientModel client = null; try { string[] args = { "200", "../../../Resources/dictionary.txt" }; server = new BoggleServer.BoggleServer(args); // create player one connection client = new BoggleClientModel(); client.Connect("localhost"); mre = new ManualResetEvent(false); // have player one join the boggle game client.SendPlayerName("Basil"); // waits for one second, expecting the callback to trigger the mre signal Assert.IsTrue(mre.WaitOne(1000)); } finally { client.Disconnect(); } }
public void BoggleClientTest10() { string[] args = { "30", "..\\..\\..\\Resources\\dictionary.txt" }; new BoggleServer.BoggleServer(args); BoggleClientModel player1 = new BoggleClientModel(); BoggleClientModel player2 = new BoggleClientModel(); player1.Connect("localhost"); player2.Connect("localhost"); player1.SendPlayerName("Basil"); player2.SendPlayerName("Lance"); player1.ScoreLineEvent += testScore; }
public void run() { BoggleServer.BoggleServer server = null; BoggleClientModel clientOne = null; BoggleClientModel clientTwo = null; try { string[] args = { "20", "../../../Resources/dictionary.txt", "jimiergsatnesaps" }; server = new BoggleServer.BoggleServer(args); // create player one connection clientOne = new BoggleClientModel(); clientOne.Connect("localhost"); // create player two connection clientTwo = new BoggleClientModel(); clientTwo.Connect("localhost"); mre1 = new ManualResetEvent(false); mre2 = new ManualResetEvent(false); // have player one join the boggle game clientOne.SendPlayerName("Basil"); // have player two join the boggle game clientTwo.SendPlayerName("Lance"); // waits for one second, expecting the callback to trigger the mre1 signal Assert.IsTrue(mre1.WaitOne(1000)); Assert.AreEqual("JIMIERGSATNESAPS", clientOne.getBoard()); Assert.AreEqual("BASIL", clientOne.getPlayerName()); // waits for one second, expecting the callback to trigger the mre2 signal Assert.IsTrue(mre2.WaitOne(1000)); Assert.AreEqual("JIMIERGSATNESAPS", clientTwo.getBoard()); Assert.AreEqual("LANCE", clientTwo.getPlayerName()); //Reset the mres mre1.Reset(); mre2.Reset(); //Check that the timer is working correctly for (int i = 0; i < 29; i++) { mre1.Reset(); mre2.Reset(); } clientOne.SendWord("to"); clientOne.SendWord("sap"); clientOne.SendWord("seat"); clientOne.SendWord("sat"); Thread.Sleep(11000); clientTwo.SendWord("to"); clientTwo.SendWord("sap"); clientTwo.SendWord("irta"); clientTwo.SendWord("rat"); //add one for to messagesReceivedOne.Add("SCORE " + 1 + " " + 0); messagesReceivedOne.Add("SCORE " + 0 + " " + 0); messagesReceivedOne.Add("SCORE " + 1 + " " + 0); //add one for to messagesReceivedTwo.Add("SCORE " + 0 + " " + 0); messagesReceivedTwo.Add("SCORE " + 0 + " " + 0); messagesReceivedTwo.Add("SCORE " + 1 + " " + 0); Thread.Sleep(11000); ////Do asserts //// waits for one second, expecting the callback to trigger the mre1 signal //Assert.IsTrue(mre1.WaitOne(1000)); //Assert.AreEqual("STOP 1 sat 1 rat 1 sap 1 seat 1 irta", s1); //// waits for one second, expecting the callback to trigger the mre2 signal //Assert.IsTrue(mre2.WaitOne(1000)); //Assert.AreEqual("STOP 1 rat 1 sat 1 sap 1 irta 1 seat", s2); } finally { server.Stop(); clientOne.Disconnect(); clientTwo.Disconnect(); } }