public void Or_operator_should_work() { var startWithJ = new AdHocSpecification <string>(n => n.StartsWith("J")); var endsWithN = new AdHocSpecification <string>(n => n.EndsWith("n")); var result = new SampleRepository().Find(startWithJ | endsWithN); CollectionAssert.Contains(result, "Jose"); CollectionAssert.Contains(result, "Julian"); CollectionAssert.DoesNotContain(result, "Manuel"); }
public void Negate_should_work() { var startWithJ = new AdHocSpecification <string>(n => n.StartsWith("J")); var specification = new NotSpecification <string>(startWithJ); var result = new SampleRepository().Find(specification); CollectionAssert.DoesNotContain(result, "Jose"); CollectionAssert.DoesNotContain(result, "Julian"); CollectionAssert.Contains(result, "Manuel"); }
public void Combination_of_boolean_operators_should_work() { var startWithM = new AdHocSpecification <string>(n => n.StartsWith("M")); var endsWithN = new AdHocSpecification <string>(n => n.EndsWith("n")); var containsU = new AdHocSpecification <string>(n => n.Contains("u")); var result = new SampleRepository().Find(startWithM | (!endsWithN & !containsU)); CollectionAssert.Contains(result, "Jose"); CollectionAssert.DoesNotContain(result, "Julian"); CollectionAssert.Contains(result, "Manuel"); }
public void And_should_work() { var startWithJ = new AdHocSpecification <string>(n => n.StartsWith("J")); var endsWithE = new AdHocSpecification <string>(n => n.EndsWith("e")); var specfication = new AndSpecification <string>(startWithJ, endsWithE); IEnumerable <string> result = new SampleRepository().Find(specfication); CollectionAssert.Contains(result, "Jose"); CollectionAssert.DoesNotContain(result, "Julian"); CollectionAssert.DoesNotContain(result, "Manuel"); }