public void InvokeMatch_ReturnMatchSpecification() { var expected = new MatchSpecification("pattern", RegexOptions.IgnoreCase); var sut = Specification.Match("pattern", RegexOptions.IgnoreCase); Assert.Equal(expected, sut, new SpecificationComparer()); }
public void InvokeNullCandidate_ReturnFalse() { var pattern = "^[1-9][0-9]{3}-[0-9]{2}-[0-9]{2}$"; var sut = new MatchSpecification(pattern); var result = sut.GetExpression().Compile().Invoke(null); Assert.False(result); }
public void NullCandidate_ReturnTrue() { var pattern = "^[0-9]{4}-[0-9]{2}-[0-9]{2}$"; var sut = new MatchSpecification(pattern); var result = sut.IsNotSatisfiedBy(null); Assert.True(result); }
public void InvokeValidCandidate_ReturnTrue() { var pattern = "^[1-9][0-9]{3}-[0-9]{2}-[0-9]{2}$"; var candidate = "2019-02-26"; var sut = new MatchSpecification(pattern); var result = sut.GetExpression().Compile().Invoke(candidate); Assert.True(result); }
public void ValidCandidate_ReturnTrue() { var pattern = "^[1-9][0-9]{3}-[0-9]{2}-[0-9]{2}$"; var candidate = "2019-02-261"; var sut = new MatchSpecification(pattern); var result = sut.IsNotSatisfiedBy(candidate); Assert.True(result); }
public void NonGenericILinqSpecification_ReturnExpressionAsAbstractExpression() { var pattern = "^[1-9][0-9]{3}-[0-9]{2}-[0-9]{2}$"; var sut = new MatchSpecification(pattern); var expected = sut.GetExpression().ToString(); var sutExpression = ((ILinqSpecification)sut).GetExpression(); var result = sutExpression.ToString(); Assert.Equal(expected, result); }
public void NullCandidate_ReturnExpectedResultObject() { var expected = new SpecificationResult("NotMatchSpecification"); var pattern = "^[1-9][0-9]{3}-[0-9]{2}-[0-9]{2}$"; var sut = new MatchSpecification(pattern); var overall = sut.IsNotSatisfiedBy(null, out var result); Assert.True(overall); Assert.Equal(expected, result, new SpecificationResultComparer()); }
public void ValidCandidate_ReturnExpectedResultObject() { var expected = new SpecificationResult("MatchSpecification"); var pattern = "^[1-9][0-9]{3}-[0-9]{2}-[0-9]{2}$"; var candidate = "2019-02-26"; var sut = new MatchSpecification(pattern); var overall = sut.IsSatisfiedBy(candidate, out var result); Assert.True(overall); Assert.Equal(expected, result, new SpecificationResultComparer()); }
public void NullCandidate_ReturnExpectedResultObject() { var expected = new SpecificationResult(false, "MatchSpecification+Failed", new FailedSpecification(typeof(MatchSpecification), new Dictionary <string, object> { { "Pattern", "^[1-9][0-9]{3}-[0-9]{2}-[0-9]{2}$" } }, (object)null, "String not match pattern [^[1-9][0-9]{3}-[0-9]{2}-[0-9]{2}$]")); var pattern = "^[1-9][0-9]{3}-[0-9]{2}-[0-9]{2}$"; var sut = new MatchSpecification(pattern); var overall = sut.IsSatisfiedBy(null, out var result); Assert.False(overall); Assert.Equal(expected, result, new SpecificationResultComparer()); }