Exemple #1
0
        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);
        }
Exemple #2
0
        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);
        }
Exemple #3
0
        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);
        }
Exemple #4
0
        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>();
        }
Exemple #5
0
        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);
        }
Exemple #6
0
        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);
        }