public void DiceParser_TokenizeParenthesesSimpleTest() { // setup test DiceParser parser = new DiceParser(); // run test List <string> result = parser.Tokenize("4d6k3 + (d8 - 2)"); // validate results Assert.IsNotNull(result); Assert.IsInstanceOfType(result, typeof(List <string>)); Assert.AreEqual(13, result.Count); Assert.AreEqual("4", result[0]); Assert.AreEqual("d", result[1]); Assert.AreEqual("6", result[2]); Assert.AreEqual("k", result[3]); Assert.AreEqual("3", result[4]); Assert.AreEqual("+", result[5]); Assert.AreEqual("(", result[6]); Assert.AreEqual("1", result[7]); Assert.AreEqual("d", result[8]); Assert.AreEqual("8", result[9]); Assert.AreEqual("-", result[10]); Assert.AreEqual("2", result[11]); Assert.AreEqual(")", result[12]); }
public void DiceParser_TokenizeSimpleConstantTest() { // setup test DiceParser parser = new DiceParser(); // run test List <string> result = parser.Tokenize("42"); // validate results Assert.IsNotNull(result); Assert.IsInstanceOfType(result, typeof(List <string>)); Assert.AreEqual(1, result.Count); Assert.AreEqual("42", result[0]); }
public void DiceParser_TokenizeExplodingNoValueTest() { // setup test DiceParser parser = new DiceParser(); // run test List <string> result = parser.Tokenize("4d6!"); // validate results Assert.IsNotNull(result); Assert.IsInstanceOfType(result, typeof(List <string>)); Assert.AreEqual(4, result.Count); Assert.AreEqual("4", result[0]); Assert.AreEqual("d", result[1]); Assert.AreEqual("6", result[2]); Assert.AreEqual("!", result[3]); }
public void DiceParser_TokenizeModifierFirstTest() { // setup test DiceParser parser = new DiceParser(); // run test List <string> result = parser.Tokenize("2+d6"); // validate results Assert.IsNotNull(result); Assert.IsInstanceOfType(result, typeof(List <string>)); Assert.AreEqual(5, result.Count); Assert.AreEqual("2", result[0]); Assert.AreEqual("+", result[1]); Assert.AreEqual("1", result[2]); Assert.AreEqual("d", result[3]); Assert.AreEqual("6", result[4]); }
public void DiceParser_TokenizeUnaryOperatorPositiveTest() { // setup test DiceParser parser = new DiceParser(); // run test List <string> result = parser.Tokenize("+1 + 4d6k3"); // validate results Assert.IsNotNull(result); Assert.IsInstanceOfType(result, typeof(List <string>)); Assert.AreEqual(7, result.Count); Assert.AreEqual("+1", result[0]); Assert.AreEqual("+", result[1]); Assert.AreEqual("4", result[2]); Assert.AreEqual("d", result[3]); Assert.AreEqual("6", result[4]); Assert.AreEqual("k", result[5]); Assert.AreEqual("3", result[6]); }
public void DiceParser_TokenizeDefaultMuliplyFirstTest() { // setup test DiceParser parser = new DiceParser(); // run test List <string> result = parser.Tokenize("2(2d6 + 1)"); // validate results Assert.IsNotNull(result); Assert.IsInstanceOfType(result, typeof(List <string>)); Assert.AreEqual(9, result.Count); Assert.AreEqual("2", result[0]); Assert.AreEqual("x", result[1]); Assert.AreEqual("(", result[2]); Assert.AreEqual("2", result[3]); Assert.AreEqual("d", result[4]); Assert.AreEqual("6", result[5]); Assert.AreEqual("+", result[6]); Assert.AreEqual("1", result[7]); Assert.AreEqual(")", result[8]); }
public void DiceParser_TokenizeChainedDiceExpressionTest() { // setup test DiceParser parser = new DiceParser(); // run test List <string> result = parser.Tokenize("4d6k3 + d8 + 3"); // validate results Assert.IsNotNull(result); Assert.IsInstanceOfType(result, typeof(List <string>)); Assert.AreEqual(11, result.Count); Assert.AreEqual("4", result[0]); Assert.AreEqual("d", result[1]); Assert.AreEqual("6", result[2]); Assert.AreEqual("k", result[3]); Assert.AreEqual("3", result[4]); Assert.AreEqual("+", result[5]); Assert.AreEqual("1", result[6]); Assert.AreEqual("d", result[7]); Assert.AreEqual("8", result[8]); Assert.AreEqual("+", result[9]); Assert.AreEqual("3", result[10]); }