コード例 #1
0
        public void IsValid_ShouldValidateChecksumForValidDateSsnWithoutDash(UseSeparator useSeparator)
        {
            var checksumValidator = Substitute.For <IValidator>();

            GetValidator(useSeparator, checksumValidator).IsValid("300974498S");

            checksumValidator.Received().IsValid("300974498S");
        }
コード例 #2
0
        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>());
        }
コード例 #3
0
        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>());
        }
コード例 #4
0
 public static string Expression(UseSeparator useSeparator)
 {
     switch (useSeparator)
     {
         case UseSeparator.No:
             return NoDashExpression;
         case UseSeparator.Yes:
             return DashExpression;
         default:
             return OptionalDashExpression;
     }
 }
コード例 #5
0
 public static string Expression(UseSeparator useSpace)
 {
     switch (useSpace)
     {
         case UseSeparator.Yes:
             return spaceExpression;
         case UseSeparator.No:
             return noSpaceExpression;
         default:
             return optionalSpaceExpression;
     }
 }
コード例 #6
0
        public static string Expression(UseSeparator useSeparator)
        {
            switch (useSeparator)
            {
            case UseSeparator.No:
                return(NoDashExpression);

            case UseSeparator.Yes:
                return(DashExpression);

            default:
                return(OptionalDashExpression);
            }
        }
コード例 #7
0
        public static string Expression(UseSeparator useSpace)
        {
            switch (useSpace)
            {
            case UseSeparator.Yes:
                return(SpaceExpression);

            case UseSeparator.No:
                return(NoSpaceExpression);

            default:
                return(OptionalSpaceExpression);
            }
        }
コード例 #8
0
 public IValidator GetValidator(UseSeparator useSpace)
 {
     return new SwedishPostalCodeAttribute(useSpace);
 }
コード例 #9
0
 public void IsValid_ShouldReturnFalseForMultipleDashes(UseSeparator useSeparator, bool expected)
 {
     Assert.That(GetValidator(useSeparator).IsValid("310108---8320"), Is.EqualTo(expected));
 }
コード例 #10
0
 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));
 }
コード例 #11
0
 public void IsValid_ShouldHandleMissingDashWithValidSsn(UseSeparator useSeparator, bool expected)
 {
     Assert.That(GetValidator(useSeparator).IsValid("3101088320"), Is.EqualTo(expected));
 }
コード例 #12
0
        public void IsValid_ShouldValidateChecksumForValidDateSsnWithoutDash(UseSeparator useSeparator)
        {
            var checksumValidator = Substitute.For<IValidator>();

            GetValidator(useSeparator, checksumValidator).IsValid("7803257518");

            checksumValidator.Received().IsValid("7803257518");
        }
コード例 #13
0
 public void IsValid_ShouldReturnTrueForEmptyString(UseSeparator useSeparator, bool expected)
 {
     Assert.That(GetValidator(useSeparator).IsValid(""), Is.EqualTo(expected));
 }
コード例 #14
0
 public SwedishPostalCodeAttribute(UseSeparator useSpace)
     : base(Expression(useSpace))
 {
 }
コード例 #15
0
 private static IValidator GetValidator(UseSeparator useSeparator, IValidator checksumValidator)
 {
     return(new FinnishSsnAttribute(useSeparator, checksumValidator));
 }
コード例 #16
0
 public void IsValid_ShouldHandleValidNonDashedSsn(UseSeparator useSeparator, bool expected)
 {
     Assert.That(GetValidator(useSeparator).IsValid("300974498S"), Is.EqualTo(expected));
 }
コード例 #17
0
 private static IValidator GetValidator(UseSeparator useSeparator)
 {
     return(new SwedishSsnAttribute(useSeparator));
 }
コード例 #18
0
 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));
 }
コード例 #19
0
 public void IsValid_ShouldHandleValidNonDashedSsn(UseSeparator useSeparator, bool expected)
 {
     Assert.That(GetValidator(useSeparator).IsValid("300974498S"), Is.EqualTo(expected));
 }
コード例 #20
0
 private static IValidator GetValidator(UseSeparator useSeparator)
 {
     return new FinnishSsnAttribute(useSeparator);
 }
コード例 #21
0
 public FinnishSsnAttribute(UseSeparator useSeparator, IValidator checksumValidator)
     : base(Expression(useSeparator))
 {
     this._checksumValidator = checksumValidator;
 }
コード例 #22
0
 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));
 }
コード例 #23
0
 public void IsValid_ShouldReturnTrueForEmptyValue(UseSeparator useSeparator, bool expected)
 {
     Assert.That(GetValidator(useSeparator).IsValid(""), Is.EqualTo(expected));
 }
コード例 #24
0
 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));
 }
コード例 #25
0
 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));
 }
コード例 #26
0
 public void IsValid_ShouldReturnTrueForNullValue(UseSeparator useSeparator, bool expected)
 {
     Assert.That(GetValidator(useSeparator).IsValid(null), Is.EqualTo(expected));
 }
コード例 #27
0
 public void IsValid_ShouldReturnFalseForMultipleDashes(UseSeparator useSeparator, bool expected)
 {
     Assert.That(GetValidator(useSeparator).IsValid("300974---498S"), Is.EqualTo(expected));
 }
コード例 #28
0
 private static IValidator GetValidator(UseSeparator useSeparator, IValidator checksumValidator)
 {
     return new SwedishSsnAttribute(useSeparator, checksumValidator);
 }
コード例 #29
0
 public SwedishSsnAttribute(UseSeparator useDash, IValidator checksumValidator)
     : base(Expression(useDash))
 {
     this._checksumValidator = checksumValidator;
 }
コード例 #30
0
 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));
 }
コード例 #31
0
 public SwedishPostalCodeAttribute(UseSeparator useSpace)
     : base(Expression(useSpace))
 {
 }
コード例 #32
0
 public SwedishSsnAttribute(UseSeparator useDash, IValidator checksumValidator)
     : base(Expression(useDash))
 {
     this._checksumValidator = checksumValidator;
 }
コード例 #33
0
 public SwedishSsnAttribute(UseSeparator useDash)
     : this(useDash, new SwedishSsnChecksumValidator())
 {
 }
コード例 #34
0
 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));
 }
コード例 #35
0
 public FinnishSsnAttribute(UseSeparator useSeparator, IValidator checksumValidator)
     : base(Expression(useSeparator))
 {
     this._checksumValidator = checksumValidator;
 }
コード例 #36
0
 public FinnishSsnAttribute(UseSeparator useSeparator)
     : this(useSeparator, new FinnishSsnChecksumValidator())
 {
 }
コード例 #37
0
 public SwedishSsnAttribute(UseSeparator useDash)
     : this(useDash, new SwedishSsnChecksumValidator())
 {
 }
コード例 #38
0
 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));
 }
コード例 #39
0
 public void IsValid_ShouldHandleMissingDashWithValidSsn(UseSeparator useSeparator, bool expected)
 {
     Assert.That(GetValidator(useSeparator).IsValid("3101088320"), Is.EqualTo(expected));
 }
コード例 #40
0
 public FinnishSsnAttribute(UseSeparator useSeparator)
     : this(useSeparator, new FinnishSsnChecksumValidator())
 {
 }
コード例 #41
0
 public IValidator GetValidator(UseSeparator useSpace)
 {
     return(new SwedishPostalCodeAttribute(useSpace));
 }