public void GreaterThan() { List <Game> list = Test("greaterThan.json"); int total = FakeGameService.GetDatas().Count(); Assert.True(list.Count > 0 && list.Count < total); }
public void ListIn() { string rules = GetJsonTestFile("listIn.json"); var items = FakeGameService.GetDatas(); bool result = JsonRuleEngine.Evaluate(items.First(), rules); Assert.True(result); }
public void Guid() { string rules = GetJsonTestFile("guid.json"); var items = FakeGameService.GetDatas(); bool result = JsonRuleEngine.Evaluate(items.First(), rules); Assert.False(result); }
private static List <Game> Test(string jsonRuleFilePath) { string rules = GetJsonTestFile(jsonRuleFilePath); var expression = JsonRuleEngine.ParseExpression <Game>(rules); var datas = FakeGameService.GetDatas(); var list = datas.Where(expression).ToList(); return(list); }
public void IsNotNull() { string rules = GetJsonTestFile("isNotNull.json"); var items = FakeGameService.GetDatas(); bool result = JsonRuleEngine.Evaluate(new Game() { Category = "Titi", Date = DateTime.UtcNow }, rules); Assert.True(result); }
public void EvaluateWithClass() { string rules = GetJsonTestFile("complex.json"); var items = FakeGameService.GetDatas(); bool result = JsonRuleEngine.Evaluate(items.First(), new ConditionRuleSet() { Field = "Name", Operator = ConditionRuleOperator.isNotNull }); Assert.True(result); }
public void ValidateExpression() { var data = File.ReadAllText(Path.Combine("TestJsons/", "complex.json")); var items = FakeGameService.GetDatas(); var whiteList = new List <string>() { "Category", "Price", "Name", "Editor.Name", "Reviews.Id" }; var result = JsonRuleEngine.ValidateExpressionFields(data, whiteList); Assert.True(result.Success); }