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"); }
public void IsNullOrEmptyCondition() { var isEmptyCondition = new IsNullOrEmptyCondition(); var expr = isEmptyCondition.For <TestSource>(x => x.Name); Assert.IsTrue(expr.Compile()(new TestSource { Name = null })); Assert.IsTrue(expr.Compile()(new TestSource { Name = string.Empty })); Assert.IsFalse(expr.Compile()(new TestSource { Name = "123" })); }