Пример #1
0
        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);
        }
Пример #2
0
        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);
        }
Пример #3
0
        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);
        }