Exemple #1
0
        public void CorrectTestResultFor_StaticMethod()
        {
            var eval = new Evaluator();

            bool result1 = eval.GetTestResult(() => Sample.GetStaticFalse());
            bool result2 = eval.GetTestResult(() => Sample.GetStaticTrue(2, "test"));

            Assert.IsFalse(result1);
            Assert.IsTrue(result2);
        }
Exemple #2
0
        public void CorrectTestResultFor_Binary()
        {
            var eval = new Evaluator();

            bool result1 = eval.GetTestResult(() => one == 2);
            bool result2 = eval.GetTestResult(() => one != 2);

            Assert.IsFalse(result1);
            Assert.IsTrue(result2);
        }
Exemple #3
0
        public void CorrectTestResultFor_InstanceMethod()
        {
            var eval = new Evaluator();
            var tester = new Sample();

            bool result1 = eval.GetTestResult(() => tester.GetFalse());
            bool result2 = eval.GetTestResult(() => tester.GetTrue(2, "test"));

            Assert.IsFalse(result1);
            Assert.IsTrue(result2);
        }
Exemple #4
0
        public void CorrectTestResultFor_UnaryNot()
        {
            var eval = new Evaluator();

            bool result1 = eval.GetTestResult(() => !(one == 1));
            bool result2 = eval.GetTestResult(() => !(_false));
            bool result3 = eval.GetTestResult(() => !(Sample.GetStaticFalse()));

            Assert.IsFalse(result1);
            Assert.IsTrue(result2);
            Assert.IsTrue(result3);
        }
Exemple #5
0
        public static void True(Expression<Func<bool>> expr, string message = "")
        {
            var eval = new Evaluator();

            if (eval.GetTestResult(expr))
                return;

            string testedCode = GetTestString(expr);

            throw new ExpertException (message)
            {
                TestedCode = testedCode,
                TestedData = eval.GetTestedValues(expr),
            };
        }