internal static string GetDescriptionString(this DiceErrorCode code) { return(typeof(DiceErrorCode) .GetMember(code.ToString())[0] .GetCustomAttributes(typeof(DescriptionAttribute), false) .Cast <DescriptionAttribute>() .Single() .Description); }
protected static void EvaluateRoll(string diceExpr, RollerConfig conf, DiceErrorCode error) { try { Roller.Roll(diceExpr, conf); Assert.Fail("Expected DiceException with error code {0}, but did not receive an exception.", error.ToString()); } catch (DiceException e) { if (e.ErrorCode != error) { Assert.Fail("Expected DiceException with error code {0}, but got error code {1}.", error.ToString(), e.ErrorCode.ToString()); } } }
/// <summary> /// Evaluates the node and asserts that a DiceException was thrown with the specified error code. /// </summary> /// <param name="node"></param> /// <param name="conf"></param> /// <param name="error"></param> protected static void EvaluateNode(DiceAST node, RollData data, DiceErrorCode error) { try { Roller.Roll(node, data); Assert.Fail("Expected DiceException with error code {0}, but did not receive an exception.", error.ToString()); } catch (DiceException e) { if (e.ErrorCode != error) { Assert.Fail("Expected DiceException with error code {0}, but got error code {1}.", error.ToString(), e.ErrorCode.ToString()); } } }
private static void EvaluatePost(string roll, DiceErrorCode error, RollPost post = null) { post = post ?? new RollPost(); try { post.AddRoll(roll); Assert.Fail("Expected DiceException with error code {0}, but did not receive an exception.", error.ToString()); } catch (DiceException e) { if (e.ErrorCode != error) { Assert.Fail("Expected DiceException with error code {0}, but got error code {1}.", error.ToString(), e.ErrorCode.ToString()); } } }