public void IsValid_ShouldValidateChecksumForValidDateSsnWithoutDash(UseSeparator useSeparator) { var checksumValidator = Substitute.For <IValidator>(); GetValidator(useSeparator, checksumValidator).IsValid("300974498S"); checksumValidator.Received().IsValid("300974498S"); }
public void IsValid_ShouldReturnFalseForInvalidDay(UseSeparator useSeparator, bool expected) { var checksumValidator = Substitute.For <IValidator>(); Assert.That(GetValidator(useSeparator, checksumValidator).IsValid("320974498S"), Is.EqualTo(expected)); Assert.That(GetValidator(useSeparator, checksumValidator).IsValid("320974-498S"), Is.EqualTo(expected)); checksumValidator.DidNotReceive().IsValid(Arg.Any <object>()); }
public void IsValid_ShouldReturnFalseForInvalidMonth(UseSeparator useSeparator, bool expected) { var checksumValidator = Substitute.For<IValidator>(); Assert.That(GetValidator(useSeparator, checksumValidator).IsValid("313108-8320"), Is.EqualTo(expected)); Assert.That(GetValidator(useSeparator, checksumValidator).IsValid("3131088320"), Is.EqualTo(expected)); checksumValidator.DidNotReceive().IsValid(Arg.Any<object>()); }
public static string Expression(UseSeparator useSeparator) { switch (useSeparator) { case UseSeparator.No: return NoDashExpression; case UseSeparator.Yes: return DashExpression; default: return OptionalDashExpression; } }
public static string Expression(UseSeparator useSpace) { switch (useSpace) { case UseSeparator.Yes: return spaceExpression; case UseSeparator.No: return noSpaceExpression; default: return optionalSpaceExpression; } }
public static string Expression(UseSeparator useSeparator) { switch (useSeparator) { case UseSeparator.No: return(NoDashExpression); case UseSeparator.Yes: return(DashExpression); default: return(OptionalDashExpression); } }
public static string Expression(UseSeparator useSpace) { switch (useSpace) { case UseSeparator.Yes: return(SpaceExpression); case UseSeparator.No: return(NoSpaceExpression); default: return(OptionalSpaceExpression); } }
public IValidator GetValidator(UseSeparator useSpace) { return new SwedishPostalCodeAttribute(useSpace); }
public void IsValid_ShouldReturnFalseForMultipleDashes(UseSeparator useSeparator, bool expected) { Assert.That(GetValidator(useSeparator).IsValid("310108---8320"), Is.EqualTo(expected)); }
public void IsValid_ShouldReturnFalseForInvalidChecksum(UseSeparator useSeparator, bool expected) { Assert.That(GetValidator(useSeparator).IsValid("7803257518"), Is.EqualTo(expected)); Assert.That(GetValidator(useSeparator).IsValid("780325-7518"), Is.EqualTo(expected)); }
public void IsValid_ShouldHandleMissingDashWithValidSsn(UseSeparator useSeparator, bool expected) { Assert.That(GetValidator(useSeparator).IsValid("3101088320"), Is.EqualTo(expected)); }
public void IsValid_ShouldValidateChecksumForValidDateSsnWithoutDash(UseSeparator useSeparator) { var checksumValidator = Substitute.For<IValidator>(); GetValidator(useSeparator, checksumValidator).IsValid("7803257518"); checksumValidator.Received().IsValid("7803257518"); }
public void IsValid_ShouldReturnTrueForEmptyString(UseSeparator useSeparator, bool expected) { Assert.That(GetValidator(useSeparator).IsValid(""), Is.EqualTo(expected)); }
public SwedishPostalCodeAttribute(UseSeparator useSpace) : base(Expression(useSpace)) { }
private static IValidator GetValidator(UseSeparator useSeparator, IValidator checksumValidator) { return(new FinnishSsnAttribute(useSeparator, checksumValidator)); }
public void IsValid_ShouldHandleValidNonDashedSsn(UseSeparator useSeparator, bool expected) { Assert.That(GetValidator(useSeparator).IsValid("300974498S"), Is.EqualTo(expected)); }
private static IValidator GetValidator(UseSeparator useSeparator) { return(new SwedishSsnAttribute(useSeparator)); }
public void IsValid_ShouldReturnFalseForTooFewCharacters(UseSeparator useSeparator, bool expected) { Assert.That(GetValidator(useSeparator).IsValid("300974498"), Is.EqualTo(expected)); Assert.That(GetValidator(useSeparator).IsValid("300974-498"), Is.EqualTo(expected)); }
private static IValidator GetValidator(UseSeparator useSeparator) { return new FinnishSsnAttribute(useSeparator); }
public FinnishSsnAttribute(UseSeparator useSeparator, IValidator checksumValidator) : base(Expression(useSeparator)) { this._checksumValidator = checksumValidator; }
public void IsValid_ShouldReturnFalseForTooFewDigits(UseSeparator useSeparator, bool expected) { Assert.That(GetValidator(useSeparator).IsValid("780325751"), Is.EqualTo(expected)); Assert.That(GetValidator(useSeparator).IsValid("780325-751"), Is.EqualTo(expected)); }
public void IsValid_ShouldReturnTrueForEmptyValue(UseSeparator useSeparator, bool expected) { Assert.That(GetValidator(useSeparator).IsValid(""), Is.EqualTo(expected)); }
public void IsValid_ShouldReturnFalseForAlphaNumericalValue(UseSeparator useSeparator, bool expected) { Assert.That(GetValidator(useSeparator).IsValid("abcdefghijklm"), Is.EqualTo(expected)); Assert.That(GetValidator(useSeparator).IsValid("abcdefghi-jklm"), Is.EqualTo(expected)); }
public void IsValid_ShouldReturnTrueForNullValue(UseSeparator useSeparator, bool expected) { Assert.That(GetValidator(useSeparator).IsValid(null), Is.EqualTo(expected)); }
public void IsValid_ShouldReturnFalseForMultipleDashes(UseSeparator useSeparator, bool expected) { Assert.That(GetValidator(useSeparator).IsValid("300974---498S"), Is.EqualTo(expected)); }
private static IValidator GetValidator(UseSeparator useSeparator, IValidator checksumValidator) { return new SwedishSsnAttribute(useSeparator, checksumValidator); }
public SwedishSsnAttribute(UseSeparator useDash, IValidator checksumValidator) : base(Expression(useDash)) { this._checksumValidator = checksumValidator; }
public void IsValid_ShouldReturnFalseForAlphaNumericalValue(UseSeparator useSeparator, bool expected) { Assert.That(GetValidator(useSeparator).IsValid("abcdefghijklm"), Is.EqualTo(expected)); Assert.That(GetValidator(useSeparator).IsValid("abcdefgh-ijklm"), Is.EqualTo(expected)); }
public SwedishSsnAttribute(UseSeparator useDash) : this(useDash, new SwedishSsnChecksumValidator()) { }
public FinnishSsnAttribute(UseSeparator useSeparator) : this(useSeparator, new FinnishSsnChecksumValidator()) { }
public void IsValid_ShouldReturnFalseForInvalidChecksum(UseSeparator useSeparator, bool expected) { Assert.That(GetValidator(useSeparator).IsValid("320974498S"), Is.EqualTo(expected)); Assert.That(GetValidator(useSeparator).IsValid("320974-498S"), Is.EqualTo(expected)); }
public IValidator GetValidator(UseSeparator useSpace) { return(new SwedishPostalCodeAttribute(useSpace)); }