예제 #1
0
 public override bool IsValid(object value)
 {
     if (value == null)
     {
         return(false);
     }
     return(TurkishIdNumber.IsValid(value.ToString()));
 }
예제 #2
0
        /// <inheritdoc/>
        protected override ValidationResult IsValid(object value, ValidationContext validationContext)
        {
            // It's impossible to call this method with a null value
            // because ValidationContext throws ArgumentNullException on null instance values.
            if (value is null)
            {
                throw new ArgumentNullException(nameof(value));
            }

            return(TurkishIdNumber.IsValid(value.ToString()) ? ValidationResult.Success
                : new ValidationResult(ErrorMessage));
        }
예제 #3
0
 public override bool IsValid(object value)
 {
     return(TurkishIdNumber.IsValid(value?.ToString()));
 }
예제 #4
0
 void stringOperator_ReturnsValue()
 {
     var id1 = new TurkishIdNumber(validTurkishId);
     Assert.AreEqual(validTurkishId, (string)id1);
 }
예제 #5
0
 void GetHashCode_SameValue_ReturnsSameHash()
 {
     var id1 = new TurkishIdNumber(validTurkishId);
     var id2 = new TurkishIdNumber(validTurkishId);
     Assert.IsTrue(id1.GetHashCode() == id2.GetHashCode());
 }
예제 #6
0
 void Equals_SameValues_ReturnsTrue()
 {
     var id1 = new TurkishIdNumber(validTurkishId);
     var id2 = new TurkishIdNumber(validTurkishId);
     Assert.IsTrue(id1.Equals(id2));
 }
예제 #7
0
 void Equals_NullTarget_ReturnsFalse()
 {
     var id1 = new TurkishIdNumber(validNumbers[0]);
     TurkishIdNumber id2 = null;
     Assert.IsFalse(id1.Equals(id2));
 }
예제 #8
0
 void Equals_DifferentValues_ReturnsFalse()
 {
     var id1 = new TurkishIdNumber(validNumbers[0]);
     var id2 = new TurkishIdNumber(validNumbers[1]);
     Assert.IsFalse(id1.Equals(id2));
 }
예제 #9
0
 void ctor_Valid_SetsValueSuccessfully()
 {
     var result = new TurkishIdNumber(validTurkishId);
     Assert.AreEqual(validTurkishId, result.Value);
     Assert.AreEqual(validTurkishId, result.ToString());
 }
예제 #10
0
 void ctor_NumericValue_ReturnCorrectsValue()
 {
     var id = new TurkishIdNumber(long.Parse(validTurkishId));
     Assert.AreEqual(validTurkishId, id.Value);
 }