public void TestTesterSerialization1() { var tester = new TreeBuilder<DataClass>(); tester.Push("name", "steve", comparison.Equals) .Push("name", "jeff", comparison.Equals) .Or(); var lambda = tester.Build(); var json = JsonConvert.SerializeObject(tester.tree); Assert.IsNotNull(json); var tree = JsonConvert.DeserializeObject<Node>(json); Assert.IsNotNull(tree); Console.WriteLine(json); }
public void TestPropTesterBasic() { var matched = new List<string>(); var not_matched = new List<string>(); var should_matched = new List<string> { "steve", "jeff" }; var should_not_matched = new List<string> { "jimbo", "george" }; var tester = new TreeBuilder<DataClass>(); tester.Push("name", "steve", comparison.Equals) .Push("name", "jeff", comparison.Equals) .Or(); var lambda = tester.Build(); foreach (var item in MakeSomeDataObjs()) { if (lambda(item)) matched.Add(item.name); else not_matched.Add(item.name); } Assert.IsTrue(Enumerable.SequenceEqual(matched.OrderBy(p => p), should_matched.OrderBy(p => p))); Assert.IsTrue(Enumerable.SequenceEqual(not_matched.OrderBy(p => p), should_not_matched.OrderBy(p => p))); }