public void negate_operator_should_work() { var startWithJ = LinqSpec.For <string>(n => n.StartsWith("J")); var result = new SampleRepository() .Retrieve(!startWithJ); result.Satisfy(r => !r.Contains("Jose") && !r.Contains("Julian") && r.Contains("Manuel")); }
public void simple_adhoc_should_work() { var specification = LinqSpec.For <string>(n => n.StartsWith("J")); var result = new SampleRepository() .Retrieve(specification); result.Satisfy(r => r.Contains("Jose") && r.Contains("Julian") && !r.Contains("Manuel")); }
public void CombineIntSpec() { var intGreaterThan4Spec = LinqSpec.For <int>(i => i > 4); var stringLongerThan4CharsSpec = LinqSpec.OnProperty <string, int>(s => s.Length, intGreaterThan4Spec); var result = new SampleRepository() .Retrieve(stringLongerThan4CharsSpec); result.Satisfy(r => !r.Contains("Jose") && r.Contains("Julian") && r.Contains("Manuel")); }
public void or_should_work() { var startWithJ = LinqSpec.For <string>(n => n.StartsWith("J")); var endsWithN = LinqSpec.For <string>(n => n.EndsWith("n")); var result = new SampleRepository() .Retrieve(startWithJ | endsWithN); result.Satisfy(r => Enumerable.Contains(r, "Jose") && Enumerable.Contains(r, "Julian") && !Enumerable.Contains(r, "Manuel")); }
public void and_should_work() { var startWithJ = LinqSpec.For <string>(n => n.StartsWith("J")); var endsWithE = LinqSpec.For <string>(n => n.EndsWith("e")); var specfication = startWithJ && endsWithE; IEnumerable <string> result = new SampleRepository() .Retrieve(specfication); result.Satisfy(r => r.Contains("Jose") && !r.Contains("Julian") && !r.Contains("Manuel")); }
public void query_sample() { var startWithM = new StartsWithQuery("M"); var endsWithN = LinqSpec.For <string>(n => n.EndsWith("n")); IEnumerable <string> result = new SampleRepository() .Retrieve(startWithM | !endsWithN); result.Satisfy(r => Enumerable.Contains(r, "Jose") && !Enumerable.Contains(r, "Julian") && Enumerable.Contains(r, "Manuel")); }
public void and_operator_should_work() { var startWithJ = LinqSpec.For <string>(n => n.StartsWith("J")); var endsWithE = LinqSpec.For <string>(n => n.EndsWith("e")); // & or && both operators behave as &&. IEnumerable <string> result = new SampleRepository() .Retrieve(startWithJ & endsWithE); result.Satisfy(r => r.Contains("Jose") && !r.Contains("Julian") && !r.Contains("Manuel")); }
public void can_cast_expression_as_queryspec() { Expression <Func <string, bool> > startExpr = n => n.StartsWith("M"); Expression <Func <string, bool> > endExpr = n => n.EndsWith("n"); LinqSpec <string> startWithM = startExpr; LinqSpec <string> endsWithN = endExpr; IEnumerable <string> result = new SampleRepository() .Retrieve(startWithM | !endsWithN); result.Satisfy(r => Enumerable.Contains(r, "Jose") && !Enumerable.Contains(r, "Julian") && Enumerable.Contains(r, "Manuel")); }