public void ItCorrecltyWorksInLinqToSql(int[] input, int[] expected) { var spec = new TestSpecification <int>(val => val > 0); var result = input.AsQueryable().Where(spec); result.Should() .BeEquivalentTo(expected); }
public void SatisfiedByHandlesNull(string value, bool expected) { var isNull = new TestSpecification <string>(val => val == null); var result = new Negated <string>(isNull).IsSatisfiedBy(value); result.Should() .Be(expected); }
public void SatisfiedByYieldCorrectResult(int value, bool expected) { var isPositive = new TestSpecification <int>(val => val > 0); var result = new Negated <int>(isPositive).IsSatisfiedBy(value); result.Should() .Be(expected); }
public void CtorThrowsIfAnyOperandIsNull() { var isPositive = new TestSpecification <int>(val => val > 0); var largerThanTen = new TestSpecification <int>(val => val > 10); Action nullOperand = () => new Or <int>(largerThanTen, null); nullOperand.Should() .Throw <ArgumentException>(); }
public void SatisfiedByHandlesNull(string value, bool expected) { var isNull = new TestSpecification <string>(val => val == null); var isEmpty = new TestSpecification <string>(val => val != null && val.Length == 0); var result = new Or <string>(isNull, isEmpty).IsSatisfiedBy(value); result.Should() .Be(expected); }
public void SatisfiedByYieldCorrectResult(int value, bool expected) { var isPositive = new TestSpecification <int>(val => val > 0); var largerThanTen = new TestSpecification <int>(val => val > 10); var largerThanFifthTen = new TestSpecification <int>(val => val > 15); var result = new Or <int>(isPositive, largerThanTen, largerThanFifthTen).IsSatisfiedBy(value); result.Should() .Be(expected); }