public void SignlessExpressionTest() { DiceParser parser = Setup("1 2 3 4"); DiceParser.ExpressionContext context = parser.expression(); DiceVisitor visitor = new DiceVisitor(); ExpressionResult result = (ExpressionResult)visitor.VisitExpression(context); result.Roll(); result.Value.Should().Be(10); }
public void SimpleExpressionTest() { DiceParser parser = Setup("3d6"); DiceParser.ExpressionContext context = parser.expression(); DiceVisitor visitor = new DiceVisitor(); ExpressionResult result = (ExpressionResult)visitor.VisitExpression(context); result.Roll(); result.Value.Should().BeGreaterOrEqualTo(3); }
public void ComplexExpressionTest() { DiceParser parser = Setup("-100 + 0d100 + 2d6 + 100"); DiceParser.ExpressionContext context = parser.expression(); DiceVisitor visitor = new DiceVisitor(); ExpressionResult result = (ExpressionResult)visitor.VisitExpression(context); result.Roll(); result.Value.Should().BeGreaterOrEqualTo(2); result.Value.Should().BeLessOrEqualTo(12); }