public void DiagonalMovePathCheck()
 {
     var m = new DiagonalMoveTemplate();
     var s = new GameState(3, 3);
     s[new Position(2, 2)] = new Piece();
     Assert.IsFalse(m.CanApply(new Position(1, 1), new Position(3, 3), s));
 }
Exemple #2
0
        public void NewEmptyPiece()
        {
            var s = new GameState(5, 5);
            var pos = new Position(3, 3);
            s[pos] = new Piece();

            s.NewEmptyPiece(pos);

            Assert.IsTrue(s[pos].IsEmpty);
        }
        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);
        }
        public void GetConcreteFromTemplate()
        {
            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 MockTemplate().Concretize(from, to);

            m.Apply(s);

            Assert.IsTrue(s[from].IsEmpty);
            Assert.AreNotEqual(s[from], movingPiece);
            Assert.AreEqual(s[to], movingPiece);
        }
Exemple #5
0
        public void GetEnumeratorTest()
        {
            const int dim = 5;
            var s = new GameState(dim, dim);

            int file = 1;
            int rank = 5;
            foreach (var p in s)
            {
                Assert.AreEqual(file, p.Pos.File);
                Assert.AreEqual(rank, p.Pos.Rank);
                if (++file > dim)
                {
                    --rank;
                    file = 1;
                }
            }
        }
 public void DiagonalMoveUpRight()
 {
     var m = new DiagonalMoveTemplate();
     var s = new GameState(5, 5);
     Assert.IsTrue(m.CanApply(new Position(3, 3), new Position(5, 5), s));
 }
 public void DiagonalMoveError()
 {
     var m = new DiagonalMoveTemplate();
     var s = new GameState(5, 5);
     Assert.IsFalse(m.CanApply(new Position(3, 3), new Position(1, 2), s));
 }
 public void VerticalMoveNotDiagonal()
 {
     var m = new VerticalMoveTemplate();
     var s = new GameState(2, 2);
     Assert.IsFalse(m.CanApply(new Position(1, 1), new Position(2, 2), s));
 }
 public void VerticalMove()
 {
     var m = new VerticalMoveTemplate();
     var s = new GameState(2, 2);
     Assert.IsTrue(m.CanApply(new Position(1, 1), new Position(1, 2), s));
 }
Exemple #10
0
 public void TemplateMovePathCheck()
 {
     var m = new MockTemplate(null, null, true);
     var s = new GameState(5, 5);
     s[new Position(3, 4)] = new Piece();
     Assert.IsFalse(m.CanApply(new Position(3, 3), new Position(3, 5), s));
 }
Exemple #11
0
 public void ItemTest()
 {
     var s = new GameState(5, 5);
     var pos = new Position(3, 3);
     Assert.IsNotNull(s[pos]);
 }
Exemple #12
0
 public void TemplateMoveNoRestrictions()
 {
     var m = new MockTemplate();
     var s = new GameState(5, 5);
     Assert.IsTrue(m.CanApply(new Position(3, 3), new Position(1, 2), s));
 }
Exemple #13
0
 public void TemplateMoveNoMaxLength()
 {
     var m = new MockTemplate(null);
     var s = new GameState(5, 5);
     Assert.IsTrue(m.CanApply(new Position(3, 3), new Position(3, 4), s));
     Assert.IsTrue(m.CanApply(new Position(3, 3), new Position(3, 5), s));
 }
Exemple #14
0
 public MockGame()
 {
     State = new GameState(5, 5);
 }
Exemple #15
0
 public void ItemTestOutOfRange()
 {
     var s = new GameState(5, 5);
     var pos = new Position(7, 7);
     var p = s[pos];
 }
Exemple #16
0
 public void HorizontalMoveBackwards()
 {
     var m = new HorizontalMoveTemplate();
     var s = new GameState(2, 2);
     Assert.IsTrue(m.CanApply(new Position(2, 1), new Position(1, 1), s));
 }
Exemple #17
0
 public void HorizontalMoveNotVertical()
 {
     var m = new HorizontalMoveTemplate();
     var s = new GameState(2, 2);
     Assert.IsFalse(m.CanApply(new Position(1, 1), new Position(1, 2), s));
 }
Exemple #18
0
 public void TemplateMoveNotCapture()
 {
     var m = new MockTemplate(null, false);
     var s = new GameState(5, 5);
     s[new Position(5, 5)] = new Piece();
     Assert.IsFalse(m.CanApply(new Position(3, 3), new Position(5, 5), s));
     Assert.IsTrue(m.CanApply(new Position(3, 3), new Position(4, 4), s));
 }