Ejemplo n.º 1
0
            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();
                }
            }
Ejemplo n.º 2
0
            public void run()
            {
                BoggleServer.BoggleServer server = new BoggleServer.BoggleServer(3, "..\\..\\customDic.txt", BoardLetters);
                BoggleConnection          conn1  = new BoggleConnection("localhost", "P1");
                BoggleConnection          conn2  = new BoggleConnection("localhost", "P2");

                conn1.ServerLost += p1LostServer;
                conn2.ServerLost += p2LostServer;

                conn1.Connect();
                conn2.Connect();

                Thread.Sleep(1000);
                server.Close();

                while (!p1Lost && !p2Lost)
                {
                    Thread.Sleep(10);
                }

                Assert.AreEqual(true, p1Lost);
                Assert.AreEqual(true, p2Lost);

                server.Close();
            }
Ejemplo n.º 3
0
            public void run()
            {
                BoggleServer.BoggleServer server = new BoggleServer.BoggleServer(1, "..\\..\\customDic.txt", sixteenAs);

                BoggleConnection conn = new BoggleConnection("localhost", "p1");

                conn.GameStarted  += gameStarted;
                conn.ScoreChanged += scoreChanged1;
                conn.TimeChanged  += timechanged1;
                conn.GameEnded    += gameEnded1;
                conn.Connect();

                BoggleConnection conn2 = new BoggleConnection("localhost", "p2");

                conn2.GameStarted  += gameStarted2;
                conn2.ScoreChanged += scoreChanged2;
                conn2.GameEnded    += gameEnded2;
                conn2.Connect();

                Thread.Sleep(1200);

                Assert.AreEqual("P2", p1Op);
                Assert.AreEqual("P1", p2Op);
                Assert.AreEqual(sixteenAs, p1Letters);
                Assert.AreEqual(sixteenAs, p2Letters);
                Assert.AreEqual("1 0", p1score1);
                Assert.AreEqual("0 1", p2score1);
                Thread.Sleep(1000);
                Assert.AreEqual("1 AAA 0  0  0  0", p1Summary);
                Assert.AreEqual("0  1 AAA 0  0  0", p2Summary);

                server.Close();
            }
Ejemplo n.º 4
0
            public void run()
            {
                BoggleServer.BoggleServer server = new BoggleServer.BoggleServer(1, "..\\..\\customDic.txt", BoardLetters);
                BoggleConnection          P1conn = new BoggleConnection("localhost", "p1");

                P1conn.GameTerminated += p1terminated;
                P1conn.Connect();

                BoggleConnection P2conn = new BoggleConnection("localhost", "p2");

                P2conn.GameTerminated += p2terminated;
                P2conn.Connect();

                Thread.Sleep(100);
                P1conn.Disconnect();
                Thread.Sleep(1000);

                Assert.AreEqual(false, p1ReceivedTERMINATED);
                Assert.AreEqual(true, p2ReceivedTERMINATED);

                server.Close();
            }
Ejemplo n.º 5
0
            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();
                }
            }