예제 #1
0
            public void NullableCandidate_ReturnFalse(int?candidate, int?greaterThan)
            {
                var sut = new GreaterThanOrEqualSpecification <int?>(greaterThan);

                var result = sut.IsNotSatisfiedBy(candidate);

                Assert.False(result);
            }
예제 #2
0
            public void GreaterThanOrEqualCandidate_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.IsNotSatisfiedBy(candidate);

                Assert.False(result);
            }
예제 #3
0
            public void CorrectNullableCandidate_ReturnExpectedResultObject(int?candidate, int?greaterThan,
                                                                            SpecificationResult expected)
            {
                var sut = new GreaterThanOrEqualSpecification <int?>(greaterThan);

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

                Assert.True(overall);
                Assert.Equal(expected, result, new SpecificationResultComparer());
            }
예제 #4
0
            public void GreaterThanOrEqualCandidate_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.IsNotSatisfiedBy(candidate, out var result);

                Assert.False(overall);
                Assert.Equal(expected, result, new SpecificationResultComparer(candidate));
            }
예제 #5
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));
        }