Пример #1
0
		public void Concat_String_UserId_String_UserLan ()	
		{
			string expression = "'a' + User!Language + 'b' + User!Language";
			var compiler = new ReportingLanguageCompiler();
			IExpression compiled = compiler.CompileExpression<object>(expression);
			Assert.That(compiled.Evaluate(null), Is.EqualTo("adeubdeu"));
		}
Пример #2
0
 public void Can_Parse_If_Then_Else_2()
 {
     const string expression = "if (true) then 'red' else 'black'";
     var compiler = new ReportingLanguageCompiler();
     IExpression expr = compiler.CompileExpression<string>(expression);
     Assert.That(expr.Evaluate(null), Is.EqualTo("red"));
 }
Пример #3
0
 public void Can_Parse_If_Then_Else_In_Complex_Context()
 {
     const string expression = "2 * (if (true) then 9 otherwise 5 + 3)^2";
     var compiler = new ReportingLanguageCompiler();
     IExpression expr = compiler.CompileExpression<int>(expression);
     Assert.That(expr.Evaluate(null),Is.EqualTo(288));
 }
Пример #4
0
 public void Can_Parse_Basic_Conditional_False_Result()
 {
     const string expression = "if (false) then 1";
     var compiler = new ReportingLanguageCompiler();
     IExpression expr = compiler.CompileExpression<int>(expression);
     Assert.That(expr.Evaluate(null), Is.EqualTo(0));
 }
Пример #5
0
		public void Can_Divide_Two_Numbers ()
		{
			string expression = "21 / 3";
			var compiler = new ReportingLanguageCompiler();
			IExpression compiled = compiler.CompileExpression<object>(expression);
			Assert.That(compiled.Evaluate(null), Is.EqualTo(7.0));
		}
Пример #6
0
		public void Concat_String_UserId ()
		{
			string expression = "'Hello:' + User!UserId";
			var compiler = new ReportingLanguageCompiler();
			IExpression compiled = compiler.CompileExpression<object>(expression);
			Assert.That(compiled.Evaluate(null), Is.EqualTo("Hello:" + Environment.UserName));
		}
Пример #7
0
		public void Concat_UserId_String ()
		{
			string expression = "User!Language + ' is my motherlanguage'";
			var compiler = new ReportingLanguageCompiler();
			IExpression compiled = compiler.CompileExpression<object>(expression);
			Assert.That(compiled.Evaluate(null), Is.EqualTo("deu is my motherlanguage"));
		}
Пример #8
0
 public void Can_Compile_Simple_Variable()
 {
     const string expression = "varName";
     var compiler = new ReportingLanguageCompiler();
     IExpression compiled = compiler.CompileExpression<string>(expression);
     Assert.That(compiled.Evaluate(null), Is.EqualTo("varName"));
 }
Пример #9
0
		public void Concat_Three_Strings ()
		{
			string expression = "'Sharp' + 'Develop' + 'Reporting'";
			var compiler = new ReportingLanguageCompiler();
			IExpression compiled = compiler.CompileExpression<object>(expression);
			Assert.That(compiled.Evaluate(null), Is.EqualTo("SharpDevelopReporting"));
		}
Пример #10
0
 public void Can_Compile_Unary_Expression()
 {
     const string expression = "!true";
     var compiler = new ReportingLanguageCompiler();
     IExpression expr = compiler.CompileExpression<bool>(expression);
     Assert.That(expr.Evaluate(null), Is.False);
 }
Пример #11
0
 public void Can_Compile_Simple_String_As_bool()
 {
     const string expression = "'tRue'";
     var compiler = new ReportingLanguageCompiler();
     IExpression compiled = compiler.CompileExpression<bool>(expression);
     Assert.That(compiled.Evaluate(null), Is.EqualTo(true));
 }
Пример #12
0
 public void Can_Compile_Simple_String()
 {
     const string expression = "'SharpReport'";
     var compiler = new ReportingLanguageCompiler();
     IExpression compiled = compiler.CompileExpression<string>(expression);
     Assert.That(compiled.Evaluate(null), Is.EqualTo("SharpReport"));
 }
Пример #13
0
 public void Can_Compile_Simple_Number()
 {
     const string expression = "1.1";
     var compiler = new ReportingLanguageCompiler();;
     IExpression compiled = compiler.CompileExpression<double>(expression);
     Assert.That(compiled.Evaluate(null), Is.EqualTo(1.1));
 }
Пример #14
0
 public void Can_Parse_If_Then_Else()
 {
     const string expression = "if (false) then 1 else 2";
     var compiler = new ReportingLanguageCompiler();
     IExpression expr = compiler.CompileExpression<int>(expression);
     Assert.That(expr.Evaluate(null), Is.EqualTo(2));
 }
Пример #15
0
		public void Can_Divide_Two_Numbers_With_Double_Parenthesis ()
		{
			string expression = "(21 / 3) + (2 * 5)";
			var compiler = new ReportingLanguageCompiler();
			IExpression compiled = compiler.CompileExpression<object>(expression);
			Assert.That(compiled.Evaluate(null), Is.EqualTo(17.0));
		}
Пример #16
0
 public void Can_Compile_Function()
 {
     const string expression = "today()";
     var compiler = new ReportingLanguageCompiler();
     IExpression expr = compiler.CompileExpression<DateTime>(expression);
     Assert.That(expr.Evaluate(null), Is.EqualTo(DateTime.Today));
 }
Пример #17
0
 public void Can_Compile_DateAdd()
 {
     const string expression = "dateAdd(today(),d,1)";
     var compiler = new ReportingLanguageCompiler();
     IExpression expr = compiler.CompileExpression<object>(expression);
     Assert.That(expr.Evaluate(null), Is.EqualTo(DateTime.Today.AddDays(1)));
 }
Пример #18
0
 public void Can_Compile_Expr_With_Generic_Return()
 {
     const string expression = "Today()";
     var compiler = new ReportingLanguageCompiler();
     IExpression expr = compiler.CompileExpression<object>(expression);
     Assert.That(expr.Evaluate(null), Is.EqualTo(DateTime.Today));
 }
Пример #19
0
        public void Can_Parse_If_Then_Else_In_Complex_Context()
        {
            const string expression = "2 * (if (true) then 9 otherwise 5 + 3)^2";
            var          compiler   = new ReportingLanguageCompiler();
            IExpression  expr       = compiler.CompileExpression <int>(expression);

            Assert.That(expr.Evaluate(null), Is.EqualTo(288));
        }
Пример #20
0
        public void Can_Parse_If_Then_Else_2()
        {
            const string expression = "if (true) then 'red' else 'black'";
            var          compiler   = new ReportingLanguageCompiler();
            IExpression  expr       = compiler.CompileExpression <string>(expression);

            Assert.That(expr.Evaluate(null), Is.EqualTo("red"));
        }
Пример #21
0
        public void Can_Parse_If_Then_Else()
        {
            const string expression = "if (false) then 1 else 2";
            var          compiler   = new ReportingLanguageCompiler();
            IExpression  expr       = compiler.CompileExpression <int>(expression);

            Assert.That(expr.Evaluate(null), Is.EqualTo(2));
        }
Пример #22
0
        public void Can_Parse_Basic_Conditional_False_Result()
        {
            const string expression = "if (false) then 1";
            var          compiler   = new ReportingLanguageCompiler();
            IExpression  expr       = compiler.CompileExpression <int>(expression);

            Assert.That(expr.Evaluate(null), Is.EqualTo(0));
        }
Пример #23
0
        public void Concat_String_UserId_String_UserLan()
        {
            string      expression = "'a' + User!Language + 'b' + User!Language";
            var         compiler   = new ReportingLanguageCompiler();
            IExpression compiled   = compiler.CompileExpression <object>(expression);

            Assert.That(compiled.Evaluate(null), Is.EqualTo("adeubdeu"));
        }
Пример #24
0
        public void Can_Divide_Two_Numbers()
        {
            string      expression = "21 / 3";
            var         compiler   = new ReportingLanguageCompiler();
            IExpression compiled   = compiler.CompileExpression <object>(expression);

            Assert.That(compiled.Evaluate(null), Is.EqualTo(7.0));
        }
Пример #25
0
        public void Can_Divide_Two_Numbers_With_Double_Parenthesis()
        {
            string      expression = "(21 / 3) + (2 * 5)";
            var         compiler   = new ReportingLanguageCompiler();
            IExpression compiled   = compiler.CompileExpression <object>(expression);

            Assert.That(compiled.Evaluate(null), Is.EqualTo(17.0));
        }
Пример #26
0
        public void Concat_String_UserId()
        {
            string      expression = "'Hello:' + User!UserId";
            var         compiler   = new ReportingLanguageCompiler();
            IExpression compiled   = compiler.CompileExpression <object>(expression);

            Assert.That(compiled.Evaluate(null), Is.EqualTo("Hello:" + Environment.UserName));
        }
Пример #27
0
        public void Can_Compile_DateAdd()
        {
            const string expression = "dateAdd(today(),d,1)";
            var          compiler   = new ReportingLanguageCompiler();
            IExpression  expr       = compiler.CompileExpression <object>(expression);

            Assert.That(expr.Evaluate(null), Is.EqualTo(DateTime.Today.AddDays(1)));
        }
Пример #28
0
        public void Concat_Three_Strings()
        {
            string      expression = "'Sharp' + 'Develop' + 'Reporting'";
            var         compiler   = new ReportingLanguageCompiler();
            IExpression compiled   = compiler.CompileExpression <object>(expression);

            Assert.That(compiled.Evaluate(null), Is.EqualTo("SharpDevelopReporting"));
        }
Пример #29
0
		public void Concat_String_FuntResult ()	
		{
			string expression = "'peter = ' + (5 * 10)";
				
			var compiler = new ReportingLanguageCompiler();
			IExpression compiled = compiler.CompileExpression<object>(expression);
			Assert.That(compiled.Evaluate(null), Is.EqualTo("peter = 50"));
		}
Пример #30
0
        public void Can_Compile_Expr_With_Generic_Return()
        {
            const string expression = "Today()";
            var          compiler   = new ReportingLanguageCompiler();
            IExpression  expr       = compiler.CompileExpression <object>(expression);

            Assert.That(expr.Evaluate(null), Is.EqualTo(DateTime.Today));
        }
Пример #31
0
        public void Concat_UserId_String()
        {
            string      expression = "User!Language + ' is my motherlanguage'";
            var         compiler   = new ReportingLanguageCompiler();
            IExpression compiled   = compiler.CompileExpression <object>(expression);

            Assert.That(compiled.Evaluate(null), Is.EqualTo("deu is my motherlanguage"));
        }
Пример #32
0
        public void Can_Compile_Simple_Variable()
        {
            const string expression = "varName";
            var          compiler   = new ReportingLanguageCompiler();
            IExpression  compiled   = compiler.CompileExpression <string>(expression);

            Assert.That(compiled.Evaluate(null), Is.EqualTo("varName"));
        }
 public void Matches_Any_Negative_Match()
 {
     var data = new[] { 1, 2, 3, 4 };
     var eStr = "MatchesAny(nothing,current > 4)";
     var compiler = new ReportingLanguageCompiler();
     var expr = compiler.CompileExpression<bool>(eStr);
     Assert.That(expr.Evaluate(new ExpressionContext(data)), Is.EqualTo(false));
 }
Пример #34
0
        public void Can_Compile_Function()
        {
            const string expression = "today()";
            var          compiler   = new ReportingLanguageCompiler();
            IExpression  expr       = compiler.CompileExpression <DateTime>(expression);

            Assert.That(expr.Evaluate(null), Is.EqualTo(DateTime.Today));
        }
 public void Matches_All_Positive_Match()
 {
     var data = new[] { 1, 2, 3, 4 };
     var eStr = "matches_all(current,current >= 1)";
     var compiler = new ReportingLanguageCompiler();
     var expr = compiler.CompileExpression<bool>(eStr);
     Assert.That(expr.Evaluate(new ExpressionContext(data)), Is.EqualTo(true));
 }
 public void Array_Handles_Divide_By_Zero()
 {
     var data = new int[]{};
     var eStr = "average()";
     var compiler = new ReportingLanguageCompiler();
     var expr = compiler.CompileExpression<double>(eStr);
     Assert.That(expr.Evaluate(new ExpressionContext(data)), Is.EqualTo(0));
 }
Пример #37
0
        public void Can_Compile_Unary_Expression()
        {
            const string expression = "!true";
            var          compiler   = new ReportingLanguageCompiler();
            IExpression  expr       = compiler.CompileExpression <bool>(expression);

            Assert.That(expr.Evaluate(null), Is.False);
        }
Пример #38
0
        public void Can_Compile_Simple_Number()
        {
            const string expression = "1.1";
            var          compiler   = new ReportingLanguageCompiler();;
            IExpression  compiled   = compiler.CompileExpression <double>(expression);

            Assert.That(compiled.Evaluate(null), Is.EqualTo(1.1));
        }
 public void Array_Average()
 {
     var data = new[] {2, 4, 6};
     var eStr = "avg()";
     var compiler = new ReportingLanguageCompiler();
     var expr = compiler.CompileExpression<double>(eStr);
     Assert.That(expr.Evaluate(new ExpressionContext(data)), Is.EqualTo(4));
 }
Пример #40
0
        public void Can_Compile_Simple_String()
        {
            const string expression = "'SharpReport'";
            var          compiler   = new ReportingLanguageCompiler();
            IExpression  compiled   = compiler.CompileExpression <string>(expression);

            Assert.That(compiled.Evaluate(null), Is.EqualTo("SharpReport"));
        }
 public void Array_Sum()
 {
     var data = new[] {1, 2, 4, 8, 16, 32, 64, 128};
     var eStr = "sum()";
     var compiler = new ReportingLanguageCompiler();
     var expr = compiler.CompileExpression<double>(eStr);
     Assert.That(expr.Evaluate(new ExpressionContext(data)), Is.EqualTo(255));
 }
Пример #42
0
        public void Can_Compile_Simple_String_As_bool()
        {
            const string expression = "'tRue'";
            var          compiler   = new ReportingLanguageCompiler();
            IExpression  compiled   = compiler.CompileExpression <bool>(expression);

            Assert.That(compiled.Evaluate(null), Is.EqualTo(true));
        }
 public void Average_Maintains_Precision()
 {
     var data = new[] {1.5, 2.0};
     var eStr = "avg()";
     var compiler = new ReportingLanguageCompiler();
     var expr = compiler.CompileExpression<double>(eStr);
     Assert.That(expr.Evaluate(new ExpressionContext(data)),Is.EqualTo(1.75));
 }
Пример #44
0
        public void Count_Will_Only_Count_Matches()
        {
            var data     = new[] { 1, 2, 3, 4 };
            var eStr     = "count(null,current > 1)";
            var compiler = new ReportingLanguageCompiler();
            var expr     = compiler.CompileExpression <int>(eStr);

            Assert.That(expr.Evaluate(new ExpressionContext(data)), Is.EqualTo(3));
        }
Пример #45
0
        public void Max_Test()
        {
            var data     = new[] { 10, 7, 3, 9 };
            var eStr     = "max(current,current * 2)";
            var compiler = new ReportingLanguageCompiler();
            var expr     = compiler.CompileExpression <int>(eStr);

            Assert.That(expr.Evaluate(new ExpressionContext(data)), Is.EqualTo(20));
        }
Пример #46
0
        public void Matches_All_Positive_Match()
        {
            var data     = new[] { 1, 2, 3, 4 };
            var eStr     = "matches_all(current,current >= 1)";
            var compiler = new ReportingLanguageCompiler();
            var expr     = compiler.CompileExpression <bool>(eStr);

            Assert.That(expr.Evaluate(new ExpressionContext(data)), Is.EqualTo(true));
        }
Пример #47
0
        public void Matches_All_Negative_Match()
        {
            var data     = new[] { 1, 2, 3, 4 };
            var eStr     = "MatchesAll(null,current > 1)";
            var compiler = new ReportingLanguageCompiler();
            var expr     = compiler.CompileExpression <bool>(eStr);

            Assert.That(expr.Evaluate(new ExpressionContext(data)), Is.EqualTo(false));
        }
Пример #48
0
        public void Average_Maintains_Precision()
        {
            var data     = new[] { 1.5, 2.0 };
            var eStr     = "avg()";
            var compiler = new ReportingLanguageCompiler();
            var expr     = compiler.CompileExpression <double>(eStr);

            Assert.That(expr.Evaluate(new ExpressionContext(data)), Is.EqualTo(1.75));
        }
Пример #49
0
        public void Average_Handles_Divide_By_Zero()
        {
            var data     = new int[] {};
            var eStr     = "average()";
            var compiler = new ReportingLanguageCompiler();
            var expr     = compiler.CompileExpression <double>(eStr);

            Assert.That(expr.Evaluate(new ExpressionContext(data)), Is.EqualTo(0));
        }
Пример #50
0
        public void Average_Test()
        {
            var data     = new[] { 2, 4, 6 };
            var eStr     = "avg()";
            var compiler = new ReportingLanguageCompiler();
            var expr     = compiler.CompileExpression <double>(eStr);

            Assert.That(expr.Evaluate(new ExpressionContext(data)), Is.EqualTo(4));
        }
Пример #51
0
        public void ItemAtIndex_Out_Of_Range_Position_Test()
        {
            var data     = new[] { "a", "c", "f" };
            var eStr     = "item_at_index(current,3)";
            var compiler = new ReportingLanguageCompiler();
            var expr     = compiler.CompileExpression <string>(eStr);

            Assert.That(expr.Evaluate(new ExpressionContext(data)), Is.Null);
        }
Пример #52
0
        public void Test_Sum()
        {
            var data     = new[] { 1, 2, 4, 8, 16, 32, 64, 128 };
            var eStr     = "sum()";
            var compiler = new ReportingLanguageCompiler();
            var expr     = compiler.CompileExpression <double>(eStr);

            Assert.That(expr.Evaluate(new ExpressionContext(data)), Is.EqualTo(255));
        }
        public void Array_Min()
        {
            var data     = new[] { 10, 7, 3, 9 };
            var eStr     = "min()";
            var compiler = new ReportingLanguageCompiler();
            var expr     = compiler.CompileExpression <int>(eStr);

            Assert.That(expr.Evaluate(new ExpressionContext(data)), Is.EqualTo(3));
        }
Пример #54
0
        public void Count_Simple_Integers()
        {
            var data     = new[] { 1, 2, 3, 4 };
            var eStr     = "count()";
            var compiler = new ReportingLanguageCompiler();
            var expr     = compiler.CompileExpression <int>(eStr);

            Assert.That(expr.Evaluate(new ExpressionContext(data)), Is.EqualTo(4));
        }
Пример #55
0
        public void Concat_String_FuntResult()
        {
            string expression = "'peter = ' + (5 * 10)";

            var         compiler = new ReportingLanguageCompiler();
            IExpression compiled = compiler.CompileExpression <object>(expression);

            Assert.That(compiled.Evaluate(null), Is.EqualTo("peter = 50"));
        }
Пример #56
0
        public void Can_Compile_Uknown_Variable()
        {
            const string expression = "varName";
            var compiler = new ReportingLanguageCompiler();
            IExpression compiled = compiler.CompileExpression<string>(expression);

            var context = new ExpressionContext(null);
            context.ResolveUnknownVariable += (sender, args) =>
                                                  {
                                                      Assert.That(args.VariableName, Is.EqualTo("varName"));
                                                      args.VariableValue = 123.456;
                                                  };
            Assert.That(compiled.Evaluate(context), Is.EqualTo("123,456"));

        }
 public void Count_Simple_Integers()
 {
     var data = new[] { 1, 2, 3, 4 };
     var eStr = "count()";
     var compiler = new ReportingLanguageCompiler();
     var expr = compiler.CompileExpression<int>(eStr);
     Assert.That(expr.Evaluate(new ExpressionContext(data)), Is.EqualTo(4));
 }
 public void Array_Max()
 {
     var data = new[] { 10, 7, 3, 9 };
     var eStr = "max(current,current * 2)";
     var compiler = new ReportingLanguageCompiler();
     var expr = compiler.CompileExpression<int>(eStr);
     Assert.That(expr.Evaluate(new ExpressionContext(data)), Is.EqualTo(20));
 }
 public void Count_Will_Only_Count_Matches()
 {
     var data = new[] { 1, 2, 3, 4 };
     var eStr = "count(null,current > 1)";
     var compiler = new ReportingLanguageCompiler();
     var expr = compiler.CompileExpression<int>(eStr);
     Assert.That(expr.Evaluate(new ExpressionContext(data)), Is.EqualTo(3));
 }
 public void ItemAtIndex_Out_Of_Range_Position_Test()
 {
     var data = new[] { "a", "c", "f" };
     var eStr = "item_at_index(current,3)";
     var compiler = new ReportingLanguageCompiler();
     var expr = compiler.CompileExpression<string>(eStr);
     Assert.That(expr.Evaluate(new ExpressionContext(data)), Is.Null);
 }