Ejemplo n.º 1
0
            public void NullRightSpecification_ArgumentNullException()
            {
                var specification = MockSpecification.True();
                var exception     = Record.Exception(() => new AndSpecification <object>(specification, null));

                Assert.NotNull(exception);
                Assert.IsType <ArgumentNullException>(exception);
            }
Ejemplo n.º 2
0
            public void NullLeftSpecification_ArgumentNullException()
            {
                var specification = MockSpecification.True();
                var exception     = Record.Exception(() => new OrSpecification <object>(null, specification));

                Assert.NotNull(exception);
                Assert.IsType <ArgumentNullException>(exception);
            }
Ejemplo n.º 3
0
            public void Compose_ReturnOrSpecification()
            {
                var sut    = new OrFluentProxy <object>(MockSpecification.True());
                var result = sut.Compose(MockSpecification.True());

                Assert.NotNull(result);
                Assert.IsType <OrSpecification <object> >(result);
            }
            public void RelatedTypes_ReturnIsSatisfiedByExecutionInExpression()
            {
                var sut = MockSpecification <IEnumerable <char> > .True();

                var expression = sut.AsExpression <ChildFakeType>();
                var result     = expression.ToString();

                Assert.Matches(@"candidate => .*\.IsSatisfiedBy\(candidate\)", result);
            }
Ejemplo n.º 5
0
            public void TrueSpecification_ReturnTrue()
            {
                var specification = MockSpecification.True();
                var sut           = new SpecificationAdapter <object>(specification);

                var result = sut.IsSatisfiedBy(new object());

                Assert.True(result);
            }
Ejemplo n.º 6
0
            public void NullCandidate_NoException()
            {
                var specification = MockSpecification.True();
                var sut           = new SpecificationAdapter <object>(specification);

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

                Assert.Null(exception);
            }
Ejemplo n.º 7
0
            public void NullSelfSpecification_ArgumentNullException()
            {
                var other = MockSpecification.True();

                var exception = Record.Exception(() => ((ISpecification <object>)null).OrNot(other));

                Assert.NotNull(exception);
                Assert.IsType <ArgumentNullException>(exception);
            }
Ejemplo n.º 8
0
            public void CorrectSpecification_ReturnOrSpecificationObject()
            {
                var sut = MockSpecification.True();

                var result = sut.OrNot <object, TrueMockSpecification>();

                Assert.NotNull(result);
                Assert.IsType <OrSpecification <object> >(result);
            }
Ejemplo n.º 9
0
            public void CorrectSpecification_ReturnProxyObject()
            {
                var sut = MockSpecification.True();

                var result = sut.OrNot();

                Assert.NotNull(result);
                Assert.IsType <OrNotFluentProxy <object> >(result);
            }
            public void ISpecification_ReturnIsSatisfiedByExecutionInExpression()
            {
                var sut = MockSpecification.True();

                var expression = sut.AsExpression();
                var result     = expression.ToString();

                Assert.Matches(@"candidate => .*\.IsSatisfiedBy\(candidate\)", result);
            }
            public void CorrectSpecification_ReturnIsSatisfiedByExecutionInExpression()
            {
                var specification = MockSpecification.True();
                var sut           = new SpecificationAdapter <object>(specification);

                var expression = sut.GetExpression();
                var result     = expression.ToString();

                Assert.Matches(@"candidate => .*\.IsSatisfiedBy\(candidate\)", result);
            }
            public void NonGenericILinqSpecification_ReturnExpressionAsAbstractExpression()
            {
                var specification = MockSpecification.True();
                var sut           = new SpecificationAdapter <object>(specification);

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

                Assert.Equal(expected.ToString(), result.ToString());
            }
            public void ISpecification_ReturnNewSpecificationAdapterObject()
            {
                var sut = MockSpecification.True();

                var result = sut.AsComplexSpecification();

                Assert.NotNull(result);
                Assert.NotEqual(sut, result);
                Assert.IsType <SpecificationAdapter <object> >(result);
            }
            public void InvalidTypeCandidate_ReturnFalse()
            {
                var specification = MockSpecification <List <int> > .True();

                var sut = new CastSpecification <IEnumerable <int>, List <int> >(specification);

                var result = sut.IsSatisfiedBy(new int[0]);

                Assert.False(result);
            }
            public void NullCandidate_NoException(bool isNegatable)
            {
                var specification =
                    isNegatable ? MockNegatableValidationSpecification.True() : MockSpecification.True();
                var sut = new SpecificationAdapter <object>(specification);

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

                Assert.Null(exception);
            }
            public void NullSelector_ArgumentNullException()
            {
                var specification = MockSpecification <string> .True();

                var exception = Record.Exception(() =>
                                                 new PropertySpecification <FakeType, string>(null, specification));

                Assert.NotNull(exception);
                Assert.IsType <ArgumentNullException>(exception);
            }
            public void NullCandidate_NoException()
            {
                var left  = MockSpecification.True();
                var right = MockSpecification.True();
                var sut   = new OrSpecification <object>(left, right);

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

                Assert.Null(exception);
            }
Ejemplo n.º 18
0
            public void CastCorrectSpecification_ReturnNegatedExpression()
            {
                var specification = MockSpecification.True();
                var sut           = new NotSpecification <object>(specification);

                var expected = sut.GetExpression();
                var result   = (Expression)sut;

                Assert.Equal(expected, result);
            }
            public void NoConversionMethod_InvalidOperationException()
            {
                var specification = MockSpecification <int> .True();

                var exception = Record.Exception(() =>
                                                 new CastSpecification <FakeType, int>(specification));

                Assert.NotNull(exception);
                Assert.IsType <InvalidOperationException>(exception);
            }
Ejemplo n.º 20
0
            public void InvokeNullCandidate_NoException()
            {
                var specification = MockSpecification <FakeType> .True();

                var sut = new CastSpecification <object, FakeType>(specification);

                var exception = Record.Exception(() => sut.GetExpression().Compile().Invoke(null));

                Assert.Null(exception);
            }
Ejemplo n.º 21
0
            public void CastCorrectSpecification_ReturnIsSatisfiedByExecutionInExpression()
            {
                var specification = MockSpecification.True();
                var sut           = new SpecificationAdapter <object>(specification);

                var expected = sut.GetExpression();
                var result   = (Expression)sut;

                Assert.Equal(expected.ToString(), result.ToString());
            }
            public void NullCandidate_NoException()
            {
                var specification = MockSpecification <FakeType> .True();

                var sut = new CastSpecification <object, FakeType>(specification);

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

                Assert.Null(exception);
            }
Ejemplo n.º 23
0
            public void CorrectSpecification_ReturnNegatedExpression()
            {
                var specification = MockSpecification.True();
                var sut           = new NotSpecification <object>(specification);

                var expression = sut.GetExpression();
                var result     = expression.ToString();

                Assert.Matches(@"candidate => Not\(.*\.IsSatisfiedBy\(candidate\)\)", result);
            }
Ejemplo n.º 24
0
            public void NonGenericILinqSpecification_ReturnBaseExpressionAsAbstractExpression()
            {
                var specification = MockSpecification.True();
                var sut           = new NotSpecification <object>(specification);

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

                Assert.Equal(expected, result);
            }
            public void TrueSpecification_ReturnTrue <T>(FakeType candidate, Expression <Func <FakeType, T> > selector)
            {
                var specification = MockSpecification <T> .True();

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

                var result = sut.IsSatisfiedBy(candidate);

                Assert.True(result);
            }
Ejemplo n.º 26
0
            public void CorrectSpecification_ReturnAndSpecificationObject()
            {
                var other = MockSpecification.True();
                var sut   = MockSpecification.True();

                var result = sut.And(other);

                Assert.NotNull(result);
                Assert.IsType <AndSpecification <object> >(result);
            }
            public void RelatedTypes_ReturnNewSpecificationAdapterObject()
            {
                var sut = MockSpecification <IEnumerable <char> > .True();

                var result = sut.AsComplexSpecification <ChildFakeType>();

                Assert.NotNull(result);
                Assert.NotSame(sut, result);
                Assert.IsType <SpecificationAdapter <ChildFakeType> >(result);
            }
            public void IncorrectSelectorExpression_ArgumentException <T>(Expression <Func <FakeType, T> > selector)
            {
                var specification = MockSpecification <T> .True();

                var exception = Record.Exception(() =>
                                                 new PropertySpecification <FakeType, T>(selector, specification));

                Assert.NotNull(exception);
                Assert.IsType <ArgumentException>(exception);
            }
            public void CorrectSpecification_ReturnIsSatisfiedByFunction()
            {
                var sut = MockSpecification.True();
                Func <object, bool> expected = sut.IsSatisfiedBy;

                var result = sut.AsPredicate();

                Assert.NotNull(result);
                Assert.Equal(expected, result);
            }
Ejemplo n.º 30
0
            public void NonGenericILinqSpecification_ReturnExpressionAsAbstractExpression()
            {
                var left  = MockSpecification.True();
                var right = MockSpecification.True();
                var sut   = new OrSpecification <object>(left, right);

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

                Assert.Equal(expected, result);
            }