コード例 #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
ファイル: SimpleMath.cs プロジェクト: Rpinski/SharpDevelop
		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
ファイル: SimpleMath.cs プロジェクト: Rpinski/SharpDevelop
		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
ファイル: StringConcat.cs プロジェクト: prid77/TickZoomPublic
        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
ファイル: StringConcat.cs プロジェクト: prid77/TickZoomPublic
        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
ファイル: StringConcat.cs プロジェクト: prid77/TickZoomPublic
        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
ファイル: StringConcat.cs プロジェクト: prid77/TickZoomPublic
        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"));
        }
コード例 #33
0
 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));
        }
コード例 #35
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));
 }
コード例 #36
0
 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));
        }
コード例 #39
0
 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"));
        }
コード例 #41
0
 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));
        }
コード例 #43
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));
 }
コード例 #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));
        }
コード例 #53
0
        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
ファイル: StringConcat.cs プロジェクト: prid77/TickZoomPublic
        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"));

        }
コード例 #57
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));
 }
コード例 #58
0
 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));
 }
コード例 #59
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));
 }
コード例 #60
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);
 }