public void Setup() { _collectionMock = new List <FakeClass>(); _collectionMock.Add(new FakeClass(0, "Alex", new DateTime(1989, 11, 14), 99.9)); _collectionMock.Add(new FakeClass(1, "Sasha", new DateTime(1989, 11, 14), 42.3)); for (int i = 0; i < 10000; i++) { _collectionMock.Add(new FakeClass(i + 2, Guid.NewGuid().ToString(), DateTime.Now, i + 42)); } Dictionary <string, object> valueStack = new Dictionary <string, object>(); BitMobile.ValueStack.CustomDictionary workflow = new BitMobile.ValueStack.CustomDictionary(); workflow.Add("name", "main"); workflow.Add("null", null); valueStack.Add("workflow", workflow); _factory = new ExpressionFactory(valueStack, typeof(FakeClass)); _factory.AddParameter("name", "Alex"); _factory.AddParameter("birth", new DateTime(1989, 11, 14)); _factory.AddParameter("money", 42.3); _factory.AddParameter("id", 1); _factory.AddParameter("collection", new string[] { "Alex", "sasha" }); }
public void LogicalStandaloneExpressionTest() { Dictionary <string, object> valueStack = new Dictionary <string, object>(); valueStack.Add("str", "test"); valueStack.Add("int", 5); valueStack.Add("date", new DateTime(1989, 11, 14)); ExpressionFactory factory = new ExpressionFactory(valueStack); factory.AddParameter("date", new DateTime(2012, 1, 1)); factory.AddParameter("null", null); bool expected = (string)factory.ValueStack["str"] == "test" && ((int)factory.ValueStack["int"] >= 5 || (DateTime)factory.ValueStack["date"] != new DateTime(1989, 11, 14) && ((DateTime)factory.Parameters["date"]).AddYears(1).Year < 2000) && ((string)factory.ValueStack["str"]).Contains("na"); var func = factory.BuildLogicalExpression(@" $str == 'test' && ( $int >= 5 || $date != 1989.11.14) && @date.AddYears(1).Year > 2000 && $str.Contains('na') && @null == NuLL"); bool actual = func(null); Assert.AreEqual(expected, actual); }