예제 #1
0
        public void TestAddLineValid()
        {
            model.Restart();

            //Add Valid Lines
            model.AddNewLine(new Point(0, 0), new Point(0, 1)); // Horizontal | Left  -> Right
            model.AddNewLine(new Point(1, 1), new Point(1, 0)); // Horizontal | Right -> Left
            model.AddNewLine(new Point(1, 0), new Point(2, 0)); // Vertical   | Top   -> Bottom
            model.AddNewLine(new Point(2, 1), new Point(1, 1)); // Vertical   | Bottom -> Top

            //There must be 4 valid lines
            Assert.AreEqual(4, model.Lines.Count);
            Assert.AreEqual(0, model.Rectangles.Count);
            Assert.AreEqual(false, model.GameEnded);

            //Add same lines
            model.AddNewLine(new Point(0, 1), new Point(0, 0)); // line0 flipped - same - no add
            model.AddNewLine(new Point(1, 0), new Point(1, 1)); // line1 flipped - same - no add
            model.AddNewLine(new Point(2, 0), new Point(1, 0)); // line2 flipped - same - no add
            model.AddNewLine(new Point(1, 1), new Point(2, 1)); // line3 flipped - same - no add

            //There must be 4 valid lines
            Assert.AreEqual(4, model.Lines.Count);
            Assert.AreEqual(0, model.Rectangles.Count);
            Assert.AreEqual(false, model.GameEnded);
        }
예제 #2
0
        private void PlayerWon(object sender, Player p)
        {
            String message;

            if (p == null)
            {
                message = "Draw";
            }
            else
            {
                message = String.Format("{0} has won with {1} points", p.PlayerName, p.Points);
            }

            MessageBox.Show(message);
            model.Restart();
            UpdateUI(this, EventArgs.Empty);
        }