public static void StringConditions(IDictionary <string, IReferenceTypeCondition <string> > conditions)
 {
     conditions["none"]             = new ReferenceTypeNoneCondition <string>("None");
     conditions["equal"]            = new ReferenceTypeEqualCondition <string>("Equal");
     conditions["notequal"]         = new ReferenceTypeNotEqualCondition <string>("NotEqual");
     conditions["contains"]         = new ContainsCondition("Contains");
     conditions["startswith"]       = new StartsWithCondition("StartsWith");
     conditions["endtswith"]        = new EndsWithCondition("EndsWith");
     conditions["isnullorempty"]    = new IsNullOrEmptyCondition("IsNullOrEmpty");
     conditions["isnotnullorempty"] = new IsNotNullOrEmptyCondition("IsNotNullOrEmpty");
 }
Example #2
0
        public void IsNotNullOrEmptyCondition()
        {
            var isNotNullOrEmptyCondition = new IsNotNullOrEmptyCondition();

            var expr = isNotNullOrEmptyCondition.For <TestSource>(x => x.Name);

            Assert.IsFalse(expr.Compile()(new TestSource {
                Name = null
            }));

            Assert.IsFalse(expr.Compile()(new TestSource {
                Name = string.Empty
            }));

            Assert.IsTrue(expr.Compile()(new TestSource {
                Name = "123"
            }));
        }