public void WhiteTagTest() { var game = new PgnGame(); var move = new PgnMove(); _state.OnEnter(move); _state.Parse('W', 'h', game); _state.Parse('h', 'i', game); _state.Parse('i', 't', game); _state.Parse('t', 'e', game); _state.Parse('e', ' ', game); _state.Parse(' ', '"', game); _state.Parse('"', 'A', game); _state.Parse('A', 'n', game); _state.Parse('n', 'a', game); _state.Parse('a', 'n', game); _state.Parse('n', 'd', game); _state.Parse('d', '"', game); _state.Parse('"', ']', game); _state.OnExit(); PgnTag tag; game.TryGetTag(PgnTag.White, out tag); Assert.AreEqual("Anand", tag.Value); }
public void DrawResultTest() { var game = new PgnGame(); var move = new PgnMove(); _state.OnEnter(move); _state.Parse('1', '.', game); _state.Parse('.', 'e', game); _state.Parse('e', '4', game); _state.Parse('4', ' ', game); _state.Parse(' ', '1', game); _state.Parse('1', '/', game); _state.Parse('/', '2', game); _state.Parse('2', '-', game); _state.Parse('-', '1', game); _state.Parse('1', '/', game); _state.Parse('/', '2', game); var result = _state.Parse('2', ' ', game); _state.OnExit(); Assert.AreEqual("1/2-1/2", game.Result); Assert.AreEqual(PgnParseResult.EndOfGame, result); }
public void RemovesAllkindsOfWhitespacesTest() { var game = new PgnGame(); var move = new PgnMove(); _state.OnEnter(move); _state.Parse('h', 'e', game); _state.Parse('e', 'l', game); _state.Parse('l', 'l', game); _state.Parse('l', 'o', game); _state.Parse('o', '\t', game); _state.Parse('\t', ' ', game); _state.Parse(' ', 'w', game); _state.Parse('w', 'o', game); _state.Parse('o', 'r', game); _state.Parse('r', 'l', game); _state.Parse('l', 'd', game); _state.Parse('d', '\r', game); _state.Parse('\r', '\n', game); _state.OnExit(); Assert.AreEqual("hello world", move.Comment); }
public void EventTagTest() { var game = new PgnGame(); var move = new PgnMove(); _state.OnEnter(move); _state.Parse('E', 'v', game); _state.Parse('v', 'e', game); _state.Parse('e', 'n', game); _state.Parse('n', 't', game); _state.Parse('t', ' ', game); _state.Parse(' ', '"', game); _state.Parse('"', 'c', game); _state.Parse('c', 'o', game); _state.Parse('o', 'o', game); _state.Parse('o', 'l', game); _state.Parse('l', '"', game); _state.Parse('"', ']', game); _state.OnExit(); PgnTag tag; game.TryGetTag(PgnTag.Event, out tag); Assert.AreEqual("cool", tag.Value); }
public void UnknownTagTest() { var game = new PgnGame(); var move = new PgnMove(); _state.OnEnter(move); _state.Parse('N', 'o', game); _state.Parse('o', 't', game); _state.Parse('t', 'O', game); _state.Parse('O', 'K', game); _state.Parse('K', ' ', game); _state.Parse(' ', '"', game); _state.Parse('"', 'A', game); _state.Parse('A', 'n', game); _state.Parse('n', 'a', game); _state.Parse('a', 'n', game); _state.Parse('n', 'd', game); _state.Parse('d', '"', game); _state.Parse('"', ']', game); _state.OnExit(); PgnTag tag; game.TryGetTag("NotOK", out tag); Assert.AreEqual("Anand", tag.Value); }
public void SmokeTest() { var game = new PgnGame(); var move = new PgnMove(); _state.OnEnter(move); _state.Parse('h', 'a', game); _state.OnExit(); Assert.AreEqual("h", move.Comment); }
public void WorstMoveNagTest() { var game = new PgnGame(); var move = new PgnMove(); _state.OnEnter(move); _state.Parse('9', ' ', game); _state.OnExit(); Assert.AreEqual("(worst move)", move.Annotation); }
public void GoodMoveNagTest() { var game = new PgnGame(); var move = new PgnMove(); _state.OnEnter(move); _state.Parse('1', ' ', game); _state.OnExit(); Assert.AreEqual("!", move.Annotation); }
public void UnknownNagTest() { var game = new PgnGame(); var move = new PgnMove(); _state.OnEnter(move); _state.Parse('1', '2', game); _state.Parse('2', '0', game); _state.OnExit(); Assert.AreEqual("$12", move.Annotation); }
public void WhiteMoveNoWhitespaceTest() { var game = new PgnGame(); var move = new PgnMove(); _state.OnEnter(move); _state.Parse('1', '.', game); _state.Parse('.', 'e', game); _state.Parse('e', '4', game); _state.Parse('4', ' ', game); _state.Parse(' ', 'e', game); _state.OnExit(); Assert.AreEqual("e4", move.Move); Assert.IsTrue(move.IsValid); }
public void OnGoingGameNoWhitespaceTest() { var game = new PgnGame(); var move = new PgnMove(); _state.OnEnter(move); _state.Parse('1', '.', game); _state.Parse('.', 'e', game); _state.Parse('e', '4', game); _state.Parse('4', '*', game); var result = _state.Parse('*', ' ', game); _state.OnExit(); Assert.AreEqual("*", game.Result); Assert.AreEqual(PgnParseResult.EndOfGame, result); }
public void WhiteMoveTest() { var game = new PgnGame(); var move = new PgnMove(); _state.OnEnter(move); _state.Parse('1', '.', game); _state.Parse('.', ' ', game); _state.Parse(' ', 'e', game); _state.Parse('e', '4', game); _state.Parse('4', ' ', game); _state.Parse(' ', 'e', game); _state.OnExit(); Assert.AreEqual("e4", move.Variation[0][0].Move); }
public void BlackWinsTest() { var game = new PgnGame(); var move = new PgnMove(); _state.OnEnter(move); _state.Parse('1', '.', game); _state.Parse('.', 'e', game); _state.Parse('e', '4', game); _state.Parse('4', ' ', game); _state.Parse(' ', '0', game); _state.Parse('0', '-', game); _state.Parse('-', '1', game); var result = _state.Parse('1', ' ', game); _state.OnExit(); Assert.AreEqual("0-1", game.Result); Assert.AreEqual(PgnParseResult.EndOfGame, result); }
public void BlackMoveNoWhitespaceTest() { var game = new PgnGame(); var move = new PgnMove(); _state.OnEnter(move); _state.Parse('1', '.', game); _state.Parse('.', 'e', game); _state.Parse('e', '4', game); _state.Parse('4', ' ', game); _state.Parse(' ', 'e', game); _state.Parse('e', '5', game); _state.Parse('5', ' ', game); _state.Parse(' ', '2', game); _state.OnExit(); Assert.AreEqual(2, move.Variation[0].Count); Assert.AreEqual("e5", move.Variation[0][1].Move); }
public void HelloWorldTest() { var game = new PgnGame(); var move = new PgnMove(); _state.OnEnter(move); _state.Parse('h', 'e', game); _state.Parse('e', 'l', game); _state.Parse('l', 'l', game); _state.Parse('l', 'o', game); _state.Parse('o', ' ', game); _state.Parse(' ', 'w', game); _state.Parse('w', 'o', game); _state.Parse('o', 'r', game); _state.Parse('r', 'l', game); _state.Parse('l', 'd', game); _state.Parse('d', '\n', game); _state.OnExit(); Assert.AreEqual("hello world", move.Comment); }