Esempio n. 1
0
        public void ResultTypeNumberNumberTest()
        {
            var exp = new And(new Number(2), new Number(4));

            Assert.Equal(ExpressionResultType.Number, exp.ResultType);
        }
Esempio n. 2
0
        public void ResultTypeBoolBoolTest()
        {
            var exp = new And(new Bool(true), new Bool(false));

            Assert.Equal(ExpressionResultType.Boolean, exp.ResultType);
        }
Esempio n. 3
0
        public void ResultTypeBoolVarTest()
        {
            var exp = new And(new Bool(true), new Variable("x"));

            Assert.Equal(ExpressionResultType.Boolean, exp.ResultType);
        }
Esempio n. 4
0
        public void ExecuteTest2()
        {
            var exp = new And(new Number(1.5), new Number(2.5));

            Assert.Equal(2.0, exp.Execute());
        }
Esempio n. 5
0
        public void ExecuteTest4()
        {
            var exp = new And(new Bool(true), new Bool(true));

            Assert.Equal(true, exp.Execute());
        }
Esempio n. 6
0
        public void ResultTypeVerVarTest()
        {
            var exp = new And(new Variable("y"), new Variable("x"));

            Assert.Equal(ExpressionResultType.Number | ExpressionResultType.Boolean, exp.ResultType);
        }
Esempio n. 7
0
        public void ExecuteTest1()
        {
            var exp = new And(new Number(1), new Number(3));

            Assert.Equal(1.0, exp.Execute());
        }
Esempio n. 8
0
        public void ResultTypeVarNumTest()
        {
            var exp = new And(new Variable("x"), new Number(1));

            Assert.Equal(ExpressionResultType.Number, exp.ResultType);
        }
Esempio n. 9
0
        public void SolveBoolTest()
        {
            var lexer = new Mock<ILexer>();
            var parser = new Mock<IParser>();
            var simplifier = new Mock<ISimplifier>();

            var strExp = "true & false";
            var exp = new And(new Bool(true), new Bool(false));

            var tokens = new List<IToken>
            {
                new BooleanToken(true),
                new OperationToken(Operations.And),
                new BooleanToken(false)
            };
            lexer.Setup(l => l.Tokenize(strExp)).Returns(() => tokens);
            parser.Setup(p => p.Parse(tokens)).Returns(() => exp);

            simplifier.Setup(s => s.Analyze(It.IsAny<And>())).Returns<And>(e => e);

            var processor = new Processor(lexer.Object, parser.Object, simplifier.Object, null);
            var result = processor.Solve<BooleanResult>(strExp);

            lexer.Verify(l => l.Tokenize(It.IsAny<string>()), Times.Once());
            parser.Verify(p => p.Parse(It.IsAny<IEnumerable<IToken>>()), Times.Once());

            Assert.Equal(false, result.Result);
        }
Esempio n. 10
0
        public void CalculateTest4()
        {
            var exp = new And(new Bool(true), new Bool(true));

            Assert.AreEqual(true, exp.Calculate());
        }
Esempio n. 11
0
        public void CalculateTest2()
        {
            var exp = new And(new Number(1.5), new Number(2.5));

            Assert.AreEqual(2, exp.Calculate());
        }
Esempio n. 12
0
        public void CalculateTest1()
        {
            var exp = new And(new Number(1), new Number(3));

            Assert.AreEqual(1, exp.Calculate());
        }