Ejemplo n.º 1
0
            public void NullCandidate_NoException(bool isValidable)
            {
                var specification = isValidable ? MockValidationSpecification.True() : MockSpecification.True();
                var sut           = new SpecificationAdapter <object>(specification);

                var exception = Record.Exception(() => sut.IsSatisfiedBy(null, out _));

                Assert.Null(exception);
            }
Ejemplo n.º 2
0
            public void TrueSpecification_ReturnExpectedResultObject(bool isValidable, SpecificationResult expected)
            {
                var specification = isValidable ? MockValidationSpecification.True() : MockSpecification.True();
                var sut           = new SpecificationAdapter <object>(specification);

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

                Assert.True(overall);
                Assert.Equal(expected, result, new SpecificationResultComparer());
            }
            public void NullCandidate_NoException()
            {
                var left  = MockValidationSpecification.True();
                var right = MockValidationSpecification.True();
                var sut   = new OrSpecification <object>(left, right);

                var exception = Record.Exception(() => sut.IsSatisfiedBy(null, out _));

                Assert.Null(exception);
            }
Ejemplo n.º 4
0
            public void RelatedValidableTypes_NoException()
            {
                var specification = MockValidationSpecification <IEnumerable <char> > .True();

                var exception = Record.Exception(() =>
                {
                    var sut = new SpecificationAdapter <ChildFakeType>(specification);
                    sut.IsSatisfiedBy(new ChildFakeType(), out _);
                });

                Assert.Null(exception);
            }
            public void TrueSpecification_ReturnExpectedResultObject <T>(FakeType candidate,
                                                                         Expression <Func <FakeType, T> > selector, SpecificationResult expected)
            {
                ISpecification <T> specification = MockValidationSpecification <T> .True();

                var sut = new PropertySpecification <FakeType, T>(selector, specification);

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

                Assert.True(overall);
                Assert.Equal(expected, result, new SpecificationResultComparer());
            }
            public void CorrectData_ReturnExpectedResultObject(bool leftResult, bool rightResult,
                                                               SpecificationResult expected)
            {
                var left  = MockValidationSpecification.Create(leftResult);
                var right = MockValidationSpecification.Create(rightResult);
                var sut   = new OrSpecification <object>(left, right);

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

                Assert.True(overall);
                Assert.Equal(expected, result, new SpecificationResultComparer());
            }
            public void CompositeRight_GroupingTraceMessage()
            {
                var left  = MockValidationSpecification.True();
                var right = new AndSpecification <object>(MockValidationSpecification.True(),
                                                          MockValidationSpecification.True());
                var sut = new OrSpecification <object>(left, right);

                sut.IsSatisfiedBy(new object(), out var result);

                Assert.Equal(
                    "TrueMockValidationSpecification Or (TrueMockValidationSpecification And TrueMockValidationSpecification)",
                    result.Trace);
            }