public void StateMove() { State o = new State(null); Assert.Empty(o.Move(1, 2, 1, 3)); Assert.Equal("Pa2a3", o.LastNote()); Assert.Contains(Ret.BadTurn, o.Move(1, 3, 1, 4)); Assert.Empty(o.Move(4, 7, 4, 5)); Assert.Contains(Ret.BadSrc, o.Move(3, 3, 4, 4)); Assert.Contains(Ret.BadDst, o.Move(6, 1, 5, 2)); Assert.Contains(Ret.InvalidMove, o.Move(5, 1, 5, 3)); o.Move(3, 2, 3, 4); Assert.Contains(Ret.Capture, o.Move(4, 5, 3, 4)); o.Move(2, 2, 2, 4); Assert.Contains(Ret.EnPassant, o.Move(3, 4, 2, 3)); Assert.Equal("Pc4b3p", o.LastNote()); }
public void StateUndo() { State o = new State(null); Assert.Empty(o.Move(1, 2, 1, 4)); Assert.Null(o.At(o.Live, 1, 2)); Assert.NotNull(o.At(o.Live, 1, 4)); Assert.False(o.At(o.Live, 1, 4).Inert); Assert.Single(o.History); o.Undo(o.LastNote()); Assert.Null(o.At(o.Live, 1, 4)); Assert.NotNull(o.At(o.Live, 1, 2)); Assert.True(o.At(o.Live, 1, 2).Inert); Assert.Empty(o.History); Assert.Empty(o.Move(1, 2, 1, 4)); Assert.Single(o.History); }