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); }
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); } }
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); }
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); }
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); }
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); } }
public void CorrectStringFor_InstanceMethodCall_WithParams() { var tester = new Sample(); TestExpressionParsing(() => tester.GetTrue(2, "test", one), "tester.GetTrue(2, \"test\", one)"); }
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); } }
public void CorrectStringFor_InstanceMemberVariable() { var tester = new Sample(); TestExpressionParsing(() => tester.One == two, "tester.One == two"); TestExpressionParsing(() => "test" == tester.Str, "\"test\" == tester.Str"); }
public void CorrectStringFor_InstanceMethodCall_NoArgs() { var tester = new Sample(); TestExpressionParsing(() => tester.GetTrue(), "tester.GetTrue()"); }
public void CorrectStringFor_UnaryNot_OnStaticMethodCall() { var tester = new Sample(); TestExpressionParsing(() => !Sample.GetStaticTrue(), "!Sample.GetStaticTrue()"); }
public void CorrectStringFor_UnaryNot_OnInstanceMethodCall() { var tester = new Sample(); TestExpressionParsing(() => !tester.GetTrue(), "!tester.GetTrue()"); }
public void CorrectStringFor_StaticMethodCall_WithParams() { var tester = new Sample(); TestExpressionParsing(() => Sample.GetStaticTrue(1, "test", two), "Sample.GetStaticTrue(1, \"test\", two)"); }
public void CorrectStringFor_StaticMethodCall_NoArgs() { var tester = new Sample(); TestExpressionParsing(() => Sample.GetStaticTrue(), "Sample.GetStaticTrue()"); }
public void CorrectStringFor_StaticMemberVariable() { var tester = new Sample(); TestExpressionParsing(() => Sample.StaticOne == two, "Sample.StaticOne == two"); TestExpressionParsing(() => "test" == Sample.StaticStr, "\"test\" == Sample.StaticStr"); }