예제 #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");
 }