public void run() { BoggleServer.BoggleServer server = null; TcpClient client = null; try { string[] args = { "200", "../../../Resources/dictionary.txt" }; server = new BoggleServer.BoggleServer(args); // create player one connection client = new TcpClient("localhost", 2000); Socket clientSocket = client.Client; StringSocket player = new StringSocket(clientSocket, new UTF8Encoding()); mre = new ManualResetEvent(false); // have player one join the boggle game player.BeginSend("PLAY Basil\n", (o, e) => { mre.Set(); }, null); // waits for one second, expecting the callback to trigger the mre signal Assert.IsTrue(mre.WaitOne(1000)); } finally { server.Stop(); client.Close(); } }
public void TestMethod1() { BoggleServer.BoggleServer twoArgServer = null; BoggleServer.BoggleServer threeArgServer = null; try { // make boggle with 2 arguments string[] twoArgs = { "200", "../../../Resources/dictionary.txt" }; twoArgServer = new BoggleServer.BoggleServer(twoArgs); } finally { // close the server twoArgServer.Stop(); } try { // make boggle with 3 arguments string[] threeArgs = { "200", "../../../Resources/dictionary.txt", "jimiergsatnesaps" }; threeArgServer = new BoggleServer.BoggleServer(threeArgs); } finally { // close the server threeArgServer.Stop(); } }
public void run() { BoggleServer.BoggleServer server = null; TcpClient clientOne = null; TcpClient clientTwo = null; try { string[] args = { "200", "../../../Resources/dictionary.txt", "jimiergsatnesaps" }; server = new BoggleServer.BoggleServer(args); // create player one connection clientOne = new TcpClient("localhost", 2000); Socket clientOneSocket = clientOne.Client; StringSocket playerOne = new StringSocket(clientOneSocket, new UTF8Encoding()); // create player two connection clientTwo = new TcpClient("localhost", 2000); Socket clientTwoSocket = clientTwo.Client; StringSocket playerTwo = new StringSocket(clientTwoSocket, new UTF8Encoding()); mre1 = new ManualResetEvent(false); mre2 = new ManualResetEvent(false); // have player one join the boggle game playerOne.BeginSend("PLAY Basil\n", (o, e) => { }, null); // have player two join the boggle game playerTwo.BeginSend("PLAY Lance\n", (o, e) => { }, null); playerOne.BeginReceive(CompletedReceiveOne, 1); playerTwo.BeginReceive(CompletedReceiveTwo, 2); // waits for one second, expecting the callback to trigger the mre1 signal Assert.IsTrue(mre1.WaitOne(1000)); Assert.AreEqual("START JIMIERGSATNESAPS 200 LANCE", s1); Assert.AreEqual(1, p1); // waits for one second, expecting the callback to trigger the mre2 signal Assert.IsTrue(mre2.WaitOne(1000)); Assert.AreEqual("START JIMIERGSATNESAPS 200 BASIL", s2); Assert.AreEqual(2, p2); } finally { server.Stop(); clientOne.Close(); clientTwo.Close(); } }
public void run() { BoggleServer.BoggleServer server = null; TcpClient clientOne = null; TcpClient clientTwo = null; try { string[] args = { "20", "../../../Resources/dictionary.txt", "jimiergsatnesaps" }; server = new BoggleServer.BoggleServer(args); // create player one connection clientOne = new TcpClient("localhost", 2000); Socket clientOneSocket = clientOne.Client; StringSocket playerOne = new StringSocket(clientOneSocket, new UTF8Encoding()); // create player two connection clientTwo = new TcpClient("localhost", 2000); Socket clientTwoSocket = clientTwo.Client; StringSocket playerTwo = new StringSocket(clientTwoSocket, new UTF8Encoding()); mre1 = new ManualResetEvent(false); mre2 = new ManualResetEvent(false); // have player one join the boggle game playerOne.BeginSend("PLAY Basil\n", (o, e) => { }, null); // have player two join the boggle game playerTwo.BeginSend("PLAY Lance\n", (o, e) => { }, null); playerOne.BeginReceive(CompletedReceiveOne, 1); playerTwo.BeginReceive(CompletedReceiveTwo, 2); // waits for one second, expecting the callback to trigger the mre1 signal Assert.IsTrue(mre1.WaitOne(1000)); Assert.AreEqual("START JIMIERGSATNESAPS 20 LANCE", s1); // waits for one second, expecting the callback to trigger the mre2 signal Assert.IsTrue(mre2.WaitOne(1000)); Assert.AreEqual("START JIMIERGSATNESAPS 20 BASIL", s2); //Reset the mres mre1.Reset(); mre2.Reset(); //Check that the timer is working correctly for (int i = 0; i < 29; i++) { //Try to get the time remaining. playerOne.BeginReceive(CompletedReceiveOne, 1); playerTwo.BeginReceive(CompletedReceiveTwo, 2); mre1.Reset(); mre2.Reset(); } playerOne.BeginSend("WORD to\n", (o, e) => { }, null); playerOne.BeginSend("WORD sap\n", (o, e) => { }, null); playerOne.BeginSend("WORD seat\n", (o, e) => { }, null); playerOne.BeginSend("WORD sat\n", (o, e) => { }, null); Thread.Sleep(11000); playerTwo.BeginSend("WORD to\n", (o, e) => { }, null); playerTwo.BeginSend("WORD sap\n", (o, e) => { }, null); playerTwo.BeginSend("WORD irta\n", (o, e) => { }, null); playerTwo.BeginSend("WORD rat\n", (o, e) => { }, null); //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.Close(); clientTwo.Close(); } }
public void run() { BoggleServer.BoggleServer server = null; TcpClient clientOne = null; TcpClient clientTwo = null; try { string[] args = { "20", "../../../Resources/dictionary.txt", "serspatglinesers" }; server = new BoggleServer.BoggleServer(args); // create player one connection clientOne = new TcpClient("localhost", 2000); Socket clientOneSocket = clientOne.Client; StringSocket playerOne = new StringSocket(clientOneSocket, new UTF8Encoding()); // create player two connection clientTwo = new TcpClient("localhost", 2000); Socket clientTwoSocket = clientTwo.Client; StringSocket playerTwo = new StringSocket(clientTwoSocket, new UTF8Encoding()); mre1 = new ManualResetEvent(false); mre2 = new ManualResetEvent(false); // have player one join the boggle game playerOne.BeginSend("PLAY Basil\n", (o, e) => { }, null); // have player two join the boggle game playerTwo.BeginSend("PLAY Lance\n", (o, e) => { }, null); playerOne.BeginReceive(CompletedReceiveOne, 1); playerTwo.BeginReceive(CompletedReceiveTwo, 2); // waits for one second, expecting the callback to trigger the mre1 signal Assert.IsTrue(mre1.WaitOne(1000)); Assert.AreEqual("START SERSPATGLINESERS 20 LANCE", s1); // waits for one second, expecting the callback to trigger the mre2 signal Assert.IsTrue(mre2.WaitOne(1000)); Assert.AreEqual("START SERSPATGLINESERS 20 BASIL", s2); //Reset the mres mre1.Reset(); mre2.Reset(); //Check that the timer is working correctly for (int i = 0; i < 29; i++) { //Try to get the time remaining. playerOne.BeginReceive(CompletedReceiveOne, 1); playerTwo.BeginReceive(CompletedReceiveTwo, 2); mre1.Reset(); mre2.Reset(); } playerOne.BeginSend("WORD step\n", (o, e) => { }, null); playerOne.BeginSend("WORD large\n", (o, e) => { }, null); playerOne.BeginSend("WORD larger\n", (o, e) => { }, null); playerOne.BeginSend("WORD genital\n", (o, e) => { }, null); playerOne.BeginSend("WORD trainers\n", (o, e) => { }, null); Thread.Sleep(22000); } finally { server.Stop(); clientOne.Close(); clientTwo.Close(); } }