public void ResultTypeNumberNumberTest() { var exp = new And(new Number(2), new Number(4)); Assert.Equal(ExpressionResultType.Number, exp.ResultType); }
public void ResultTypeBoolBoolTest() { var exp = new And(new Bool(true), new Bool(false)); Assert.Equal(ExpressionResultType.Boolean, exp.ResultType); }
public void ResultTypeBoolVarTest() { var exp = new And(new Bool(true), new Variable("x")); Assert.Equal(ExpressionResultType.Boolean, exp.ResultType); }
public void ExecuteTest2() { var exp = new And(new Number(1.5), new Number(2.5)); Assert.Equal(2.0, exp.Execute()); }
public void ExecuteTest4() { var exp = new And(new Bool(true), new Bool(true)); Assert.Equal(true, exp.Execute()); }
public void ResultTypeVerVarTest() { var exp = new And(new Variable("y"), new Variable("x")); Assert.Equal(ExpressionResultType.Number | ExpressionResultType.Boolean, exp.ResultType); }
public void ExecuteTest1() { var exp = new And(new Number(1), new Number(3)); Assert.Equal(1.0, exp.Execute()); }
public void ResultTypeVarNumTest() { var exp = new And(new Variable("x"), new Number(1)); Assert.Equal(ExpressionResultType.Number, exp.ResultType); }
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); }
public void CalculateTest4() { var exp = new And(new Bool(true), new Bool(true)); Assert.AreEqual(true, exp.Calculate()); }
public void CalculateTest2() { var exp = new And(new Number(1.5), new Number(2.5)); Assert.AreEqual(2, exp.Calculate()); }
public void CalculateTest1() { var exp = new And(new Number(1), new Number(3)); Assert.AreEqual(1, exp.Calculate()); }