public void InvokeNull_NotRaiseException(bool isLinq) { var specification = isLinq ? new MockLinqSpecification <object>(obj => true) : MockSpecification.True(); var sut = new SpecificationAdapter <object>(specification); var exception = Record.Exception(() => sut.GetExpression().Compile().Invoke(null)); Assert.Null(exception); }
public void InvokeTrueSpecification_ReturnTrue(bool isLinq) { var specification = isLinq ? new MockLinqSpecification <object>(obj => true) : MockSpecification.True(); var sut = new SpecificationAdapter <object>(specification); var result = sut.GetExpression().Compile().Invoke(new object()); Assert.True(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 CorrectLinqSpecification_ReturnBaseExpression() { Expression <Func <object, bool> > expected = obj => true; var specification = new MockLinqSpecification <object>(expected); var sut = new SpecificationAdapter <object>(specification); var result = sut.GetExpression(); Assert.Equal(expected, 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 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 InvokeRelatedLinqTypes_NoException() { var specification = MockSpecification <IEnumerable <char> > .True(); var exception = Record.Exception(() => { var sut = new SpecificationAdapter <ChildFakeType>(specification); sut.GetExpression().Compile().Invoke(new ChildFakeType()); }); Assert.Null(exception); }