public void diceFormulaRegexValidity() { DiceInterpreter diceEngine = new DiceInterpreter(); Dictionary <string, bool> diceFormulaTestStrings = new Dictionary <string, bool>(); diceFormulaTestStrings.Add("2", true); diceFormulaTestStrings.Add("1w6", true); diceFormulaTestStrings.Add("3w2+1", true); diceFormulaTestStrings.Add("9w4-3", true); diceFormulaTestStrings.Add("10w31-20", true); diceFormulaTestStrings.Add("123w456+789", true); diceFormulaTestStrings.Add("-1w6", false); diceFormulaTestStrings.Add("(1w6)", false); diceFormulaTestStrings.Add("a", false); diceFormulaTestStrings.Add("3w5+2w4", false); diceFormulaTestStrings.Add("3w5+", false); foreach (string testStr in diceFormulaTestStrings.Keys) { bool isMatching = diceEngine.isValidDiceFormula(testStr); TestContext.WriteLine("Evaluating \t{0} returns \t{1} should be \t{2}", testStr, isMatching, diceFormulaTestStrings[testStr]); if (diceFormulaTestStrings[testStr]) { Assert.True(isMatching); } else { Assert.False(isMatching); } } }