-
-
Notifications
You must be signed in to change notification settings - Fork 245
Expand file tree
/
Copy pathExpressionParserTests.cs
More file actions
73 lines (64 loc) · 2.7 KB
/
ExpressionParserTests.cs
File metadata and controls
73 lines (64 loc) · 2.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
using System.Linq.Dynamic.Core.Parser;
using System.Linq.Expressions;
using NFluent;
using Xunit;
namespace System.Linq.Dynamic.Core.Tests.Parser
{
public class ExpressionParserTests
{
[Theory]
[InlineData("it == 1", "(x == 1)")]
[InlineData("it eq 1", "(x == 1)")]
[InlineData("it equal 1", "(x == 1)")]
[InlineData("it != 1", "(x != 1)")]
[InlineData("it ne 1", "(x != 1)")]
[InlineData("it neq 1", "(x != 1)")]
[InlineData("it notequal 1", "(x != 1)")]
[InlineData("it lt 1", "(x < 1)")]
[InlineData("it LessThan 1", "(x < 1)")]
[InlineData("it le 1", "(x <= 1)")]
[InlineData("it LessThanEqual 1", "(x <= 1)")]
[InlineData("it gt 1", "(x > 1)")]
[InlineData("it GreaterThan 1", "(x > 1)")]
[InlineData("it ge 1", "(x >= 1)")]
[InlineData("it GreaterThanEqual 1", "(x >= 1)")]
public void Parse_ParseComparisonOperator(string expression, string result)
{
// Arrange
ParameterExpression[] parameters = { ParameterExpressionHelper.CreateParameterExpression(typeof(int), "x") };
var sut = new ExpressionParser(parameters, expression, null, null);
// Act
var parsedExpression = sut.Parse(null).ToString();
// Assert
Check.That(parsedExpression).Equals(result);
}
[Theory]
[InlineData("it || true", "(x OrElse True)")]
[InlineData("it or true", "(x OrElse True)")]
[InlineData("it OrElse true", "(x OrElse True)")]
public void Parse_ParseOrOperator(string expression, string result)
{
// Arrange
ParameterExpression[] parameters = { ParameterExpressionHelper.CreateParameterExpression(typeof(bool), "x") };
var sut = new ExpressionParser(parameters, expression, null, null);
// Act
var parsedExpression = sut.Parse(null).ToString();
// Assert
Check.That(parsedExpression).Equals(result);
}
[Theory]
[InlineData("it && true", "(x AndAlso True)")]
[InlineData("it and true", "(x AndAlso True)")]
[InlineData("it AndAlso true", "(x AndAlso True)")]
public void Parse_ParseAndOperator(string expression, string result)
{
// Arrange
ParameterExpression[] parameters = { ParameterExpressionHelper.CreateParameterExpression(typeof(bool), "x") };
var sut = new ExpressionParser(parameters, expression, null, null);
// Act
var parsedExpression = sut.Parse(null).ToString();
// Assert
Check.That(parsedExpression).Equals(result);
}
}
}