├── .gitignore
├── MicroRuleEngine.Core.Tests
├── ExampleUsage.cs
├── ExpressionToSQLQueryTest.cs
├── InMemoryEntityFrameworkTests.cs
├── MicroRuleEngine.Core.Tests.csproj
└── Models
│ ├── Blog.cs
│ └── Order.cs
├── MicroRuleEngine.Tests
├── DataRowTest.cs
├── ExampleUsage.cs
├── ExceptionTests.cs
├── IsTypeTests.cs
├── MicroRuleEngine.Tests.csproj
├── Models
│ ├── MemberOperaterMemberTestObject.cs
│ └── Order.cs
├── NewAPI.cs
├── Properties
│ └── AssemblyInfo.cs
├── SerializationTests.cs
└── TimeTest.cs
├── MicroRuleEngine.sln
├── MicroRuleEngine
├── MRE.cs
└── MicroRuleEngine.csproj
├── Nuget
├── CreatePackage.bat
└── MRE.nuspec
├── README.md
└── license.txt
/.gitignore:
--------------------------------------------------------------------------------
1 | bin
2 | obj
3 | TestResults
4 | TestResult.xml
5 | content
6 | *.nupkg
7 | *.suo
8 | *.log
9 | *.cache
10 | *.user
11 | *.tmp
12 | *.ldf
13 | *.mdf
14 | *.swx
15 | *.vsmdi
16 | *.testsettings
17 | /.vs
18 | /ConsoleApp1
19 | /packages
20 | /MicroRuleEngine.Tests.psess
21 | /ConsoleApp1.psess
22 | /ConsoleApp1-3.psess
23 | /ConsoleApp1-2.psess
24 | /ConsoleApp1-1.psess
25 | /MicroRuleEngine/MRE1.cs
26 | privateKey.key
27 |
--------------------------------------------------------------------------------
/MicroRuleEngine.Core.Tests/ExampleUsage.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Linq.Expressions;
5 | using Microsoft.VisualStudio.TestTools.UnitTesting;
6 | using MicroRuleEngine.Core.Tests.Models;
7 |
8 | namespace MicroRuleEngine.Tests
9 | {
10 | ///
11 | /// Summary description for UnitTest1
12 | ///
13 | [TestClass]
14 | public class ExampleUsage
15 | {
16 | [TestMethod]
17 | public void ChildPropertiesOfNull()
18 | {
19 | Order order = GetOrder();
20 | order.Customer = null;
21 | Rule rule = new Rule
22 | {
23 | MemberName = "Customer.Country.CountryCode",
24 | Operator = ExpressionType.Equal.ToString("g"),
25 | TargetValue = "AUS"
26 | };
27 | MRE engine = new MRE();
28 | var compiledRule = engine.CompileRule(rule);
29 | bool passes = compiledRule(order);
30 | Assert.IsFalse(passes);
31 | }
32 |
33 | [TestMethod]
34 | public void GetAllField()
35 | {
36 | Order order = GetOrder();
37 |
38 | var type = order.GetType();
39 | var members = MRE.Member.GetFields(type);
40 | Assert.IsTrue(
41 | members.Where(x=> x.Name == "Customer.Country.CountryCode" && x.PossibleOperators.Any(y=> y.Name == "StartsWith")).Any()
42 | );
43 | }
44 |
45 | [TestMethod]
46 | public void CoerceMethod()
47 | {
48 | Order order = GetOrder();
49 | Rule rule = new Rule
50 | {
51 | MemberName = "Codes",
52 | Operator = "Contains",
53 | TargetValue = "243",
54 | Inputs = new List