Esempio n. 1
0
        public void AddMove()
        {
            var g    = new MockGame();
            var from = new Position(1, 1);
            var to   = new Position(2, 2);
            var m    = new ConcreteMove(from, to);

            g.AddMove(m);

            Assert.AreEqual(1, g.MovesCount);
        }
        public void CaptureMove()
        {
            var s = new GameState(5, 5);
            var from = new Position(1, 1);
            var to = new Position(2, 2);
            s[from] = new Piece();
            var movingPiece = s[from];
            s[to] = new Piece();
            var m = new ConcreteMove(from, to);

            m.Apply(s);

            Assert.AreEqual(s[to], movingPiece);
        }
Esempio n. 3
0
        public void MakeMoveIsStateChanged()
        {
            var g = new MockGame();
            var from = new Position(1, 1);
            var to = new Position(2, 2);
            var p = new Piece();
            var m = new ConcreteMove(from, to);
            g.State[from] = p;
            p.Move(from);
            g.AddMove(m);

            g.MakeMove();

            Assert.AreEqual(p, g.State[to]);
        }
Esempio n. 4
0
        public void MakeMove()
        {
            var g = new MockGame();
            var from = new Position(1, 1);
            var to = new Position(2, 2);
            var p  = new Piece();
            var m = new ConcreteMove(from, to);
            g.State[from] = p;
            p.Move(from);
            g.AddMove(m);

            bool result = g.MakeMove();

            Assert.AreEqual(1, g.MovesCount);
            Assert.AreEqual(1, g.CurrentMove);
            Assert.IsTrue(result);
        }
        public void SimpleMove()
        {
            var s = new GameState(5, 5);
            var from = new Position(1, 1);
            var to = new Position(2, 2);
            s[from] = new Piece();
            var movingPiece = s[from];
            var m = new ConcreteMove(from, to);

            m.Apply(s);

            Assert.IsTrue(s[from].IsEmpty);
            Assert.AreNotEqual(s[from], movingPiece);
            Assert.AreEqual(s[to], movingPiece);
        }