Пример #1
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);
        }
Пример #2
0
 public void OnException_TestedCodeIsSet_MemberVariables()
 {
     try
     {
         var tester = new Sample();
         Its.True(() => tester.One == tester.Two);
     }
     catch (ExpertException ex)
     {
         Assert.AreEqual("tester.One == tester.Two", ex.TestedCode);
     }
 }
Пример #3
0
        public void CorrectValuesFor_Unary_On_StaticCall()
        {
            var eval = new Evaluator();
            var tester = new Sample();
            Expression<Func<bool>> expr = () => !(Sample.GetStaticFalse());

            object[] values = eval.GetUnaryValues(expr.Body);

            Assert.AreEqual(values.Length, 1);
            Assert.AreEqual(values[0], false);
        }
Пример #4
0
        public void CorrectValueFor_MemberVariableExpr_Instance()
        {
            var tester = new Sample();
            var eval = new Evaluator();
            Expression<Func<bool>> expr = () => one == tester.Two;
            Expression rightExpr = (expr.Body as BinaryExpression).Right;

            object rightVal = eval.GetMemberVal(rightExpr);

            Assert.AreEqual(rightVal, 2);
        }
Пример #5
0
        public void CorrectValueFor_InstanceCallExpr_ValueType()
        {
            var eval = new Evaluator();
            var tester = new Sample();
            Expression<Func<bool>> expr = () => tester.GetTrue();
            Expression call = (expr.Body as MethodCallExpression);

            object val = eval.GetMemberVal(call);

            Assert.AreEqual(val, true);
        }
Пример #6
0
 public void OnException_TestedDataIsSet_Binary_MemberAccess()
 {
     try
     {
         var tester = new Sample();
         Its.True(() => tester.One == tester.Two);
     }
     catch (ExpertException ex)
     {
         Assert.AreEqual(ex.TestedData.Length, 2);
         Assert.AreEqual(ex.TestedData[0], 1);
         Assert.AreEqual(ex.TestedData[1], 2);
     }
 }
Пример #7
0
 public void CorrectStringFor_InstanceMethodCall_WithParams()
 {
     var tester = new Sample();
     TestExpressionParsing(() => tester.GetTrue(2, "test", one), "tester.GetTrue(2, \"test\", one)");
 }
Пример #8
0
 public void OnException_TestedDataIsSet_MethodCall()
 {
     try
     {
         var tester = new Sample();
         Its.True(() => tester.GetFalse());
     }
     catch (ExpertException ex)
     {
         Assert.AreEqual(ex.TestedData.Length, 1);
         Assert.AreEqual(ex.TestedData[0], false);
     }
 }
Пример #9
0
 public void CorrectStringFor_InstanceMemberVariable()
 {
     var tester = new Sample();
     TestExpressionParsing(() => tester.One == two, "tester.One == two");
     TestExpressionParsing(() => "test" == tester.Str, "\"test\" == tester.Str");
 }
Пример #10
0
 public void CorrectStringFor_InstanceMethodCall_NoArgs()
 {
     var tester = new Sample();
     TestExpressionParsing(() => tester.GetTrue(), "tester.GetTrue()");
 }
Пример #11
0
 public void CorrectStringFor_UnaryNot_OnStaticMethodCall()
 {
     var tester = new Sample();
     TestExpressionParsing(() => !Sample.GetStaticTrue(), "!Sample.GetStaticTrue()");
 }
Пример #12
0
 public void CorrectStringFor_UnaryNot_OnInstanceMethodCall()
 {
     var tester = new Sample();
     TestExpressionParsing(() => !tester.GetTrue(), "!tester.GetTrue()");
 }
Пример #13
0
 public void CorrectStringFor_StaticMethodCall_WithParams()
 {
     var tester = new Sample();
     TestExpressionParsing(() => Sample.GetStaticTrue(1, "test", two), "Sample.GetStaticTrue(1, \"test\", two)");
 }
Пример #14
0
 public void CorrectStringFor_StaticMethodCall_NoArgs()
 {
     var tester = new Sample();
     TestExpressionParsing(() => Sample.GetStaticTrue(), "Sample.GetStaticTrue()");
 }
Пример #15
0
 public void CorrectStringFor_StaticMemberVariable()
 {
     var tester = new Sample();
     TestExpressionParsing(() => Sample.StaticOne == two, "Sample.StaticOne == two");
     TestExpressionParsing(() => "test" == Sample.StaticStr, "\"test\" == Sample.StaticStr");
 }