public void IsTrueIn_GivenJsonObjectsAndEasyRule_ValidReturn(string easyRule, bool expectedResult = true) { // Arrange... var jsonWorld = @"{ 'Stores': [ 'Lambton Quay', 'Willis Street' ], 'Prices': [ 10, 10 ], 'MaxPrice': 10, 'Buyers': [ 'John', 'Sam' ], 'Seller': 'John', 'Owners': [ 'Sam', 'Steve' ], 'Manufacturers': [ { 'Name': 'Acme Co', 'Products': [ { 'Name': 'Anvil', 'Price': 50 } ] }, { 'Name': 'Contoso', 'Products': [ { 'Name': 'Elbow Grease', 'Price': 99.95 }, { 'Name': 'Headlight Fluid', 'Price': 4 } ] } ] }"; var sut = JsonEasyRuleEvaluator.CreateEvaluator(); // Act... var result = sut.IsTrueIn(easyRule, jsonWorld); // Assert... Assert.AreEqual(expectedResult, result); }
public void JsonWorldsToRules_SubmitJsonObjects_ExpectInferredRules() { // Arrange... var jsonWorlds = new List <string>(); jsonWorlds.Add("{'Name':'Bob', 'Age':'40', 'Year': '2040'}"); jsonWorlds.Add("{'Name':'Bob', 'Age':'30', 'Year': '2030'}"); jsonWorlds.Add("{'Name':'Sam', 'Age':'30', 'Year': '2030'}"); jsonWorlds.Add("{'Name':'Tom', 'Age':'30', 'Year': '2010'}"); var expectedRules = new List <string>(); expectedRules.Add("IF (Year) IS (2030) THEN (Age) IS (30)"); var sut = JsonEasyRuleEvaluator.CreateEvaluator(); // Act... var result = sut.InferEasyRules(jsonWorlds); // Assert... Assert.AreEqual(expectedRules, result); }