コード例 #1
0
            public void InvokeNullableCandidate_ReturnFalse(int?candidate, int?greaterThan)
            {
                var sut = new GreaterThanOrEqualSpecification <int?>(greaterThan);

                var result = sut.GetExpression().Compile().Invoke(candidate);

                Assert.False(result);
            }
            public void NullableCandidate_ReturnFalse(int?candidate, int?greaterThan)
            {
                var sut = new GreaterThanOrEqualSpecification <int?>(greaterThan);

                var result = sut.IsSatisfiedBy(candidate);

                Assert.False(result);
            }
            public void NotGreaterThanOrEqualCandidate_ReturnFalse <T>(T candidate, T greaterThan, IComparer <T> comparer)
            {
                candidate = candidate?.ToString() != "null" ? candidate : default;
                var sut = new GreaterThanOrEqualSpecification <T>(greaterThan, comparer);

                var result = sut.IsSatisfiedBy(candidate);

                Assert.False(result);
            }
        public void InvokeGreaterThanOrEqual_ReturnGreaterThanOrEqualSpecification()
        {
            var comparer = new FakeIntComparer();
            var expected = new GreaterThanOrEqualSpecification <int>(0, comparer);

            var sut = Specification.GreaterThanOrEqual(0, comparer);

            Assert.Equal(expected, sut, new SpecificationComparer());
        }
            public void CorrectNullableCandidate_ReturnExpectedResultObject(int?candidate, int?greaterThan,
                                                                            SpecificationResult expected)
            {
                var sut = new GreaterThanOrEqualSpecification <int?>(greaterThan);

                var overall = sut.IsSatisfiedBy(candidate, out var result);

                Assert.True(overall);
                Assert.Equal(expected, result, new SpecificationResultComparer());
            }
コード例 #6
0
            public void NonGenericILinqSpecification_ReturnExpressionAsAbstractExpression()
            {
                var sut = new GreaterThanOrEqualSpecification <string>(null);

                var expected      = sut.GetExpression().ToString();
                var sutExpression = ((ILinqSpecification)sut).GetExpression();
                var result        = sutExpression.ToString();

                Assert.Equal(expected, result);
            }
コード例 #7
0
            public void InvokeNotGreaterThanOrEqualCandidate_ReturnFalse <T>(T candidate, T greaterThan,
                                                                             IComparer <T> comparer)
            {
                candidate = candidate?.ToString() != "null" ? candidate : default;
                var sut = new GreaterThanOrEqualSpecification <T>(greaterThan, comparer);

                var result = sut.GetExpression().Compile().Invoke(candidate);

                Assert.False(result);
            }
            public void NotGreaterThanOrEqualCandidate_ReturnExpectedResultObject <T>(T candidate, T greaterThan,
                                                                                      IComparer <T> comparer, SpecificationResult expected)
            {
                candidate = candidate?.ToString() != "null" ? candidate : default;
                var sut = new GreaterThanOrEqualSpecification <T>(greaterThan, comparer);

                var overall = sut.IsSatisfiedBy(candidate, out var result);

                Assert.False(overall);
                Assert.Equal(expected, result, new SpecificationResultComparer(candidate));
            }
コード例 #9
0
        protected BaseBetweenSpecification(T from, T to, bool inclusive, IComparer<T> comparer)
        {
            From = from;
            To = to;

            if (inclusive)
            {
                _lessThanSpecification = new LessThanOrEqualSpecification<T>(to, comparer);
                _greaterThanSpecification = new GreaterThanOrEqualSpecification<T>(from, comparer);
            }
            else
            {
                _lessThanSpecification = new LessThanSpecification<T>(to, comparer);
                _greaterThanSpecification = new GreaterThanSpecification<T>(from, comparer);
            }

            var fromGreaterThanSpec = new GreaterThanOrEqualSpecification<T>(from, comparer);
            if (fromGreaterThanSpec.IsNotSatisfiedBy(to))
                throw new ArgumentException("To must be greater than From", nameof(to));
        }