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)); }
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); }
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)); }
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)); }
public void ItemTest() { var s = new GameState(5, 5); var pos = new Position(3, 3); Assert.IsNotNull(s[pos]); }
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)); }
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)); }
public MockGame() { State = new GameState(5, 5); }
public void ItemTestOutOfRange() { var s = new GameState(5, 5); var pos = new Position(7, 7); var p = s[pos]; }
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)); }
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)); }
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)); }