public override bool IsValid(object value) { if (value == null) { return(false); } return(TurkishIdNumber.IsValid(value.ToString())); }
/// <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)); }
public override bool IsValid(object value) { return(TurkishIdNumber.IsValid(value?.ToString())); }
void stringOperator_ReturnsValue() { var id1 = new TurkishIdNumber(validTurkishId); Assert.AreEqual(validTurkishId, (string)id1); }
void GetHashCode_SameValue_ReturnsSameHash() { var id1 = new TurkishIdNumber(validTurkishId); var id2 = new TurkishIdNumber(validTurkishId); Assert.IsTrue(id1.GetHashCode() == id2.GetHashCode()); }
void Equals_SameValues_ReturnsTrue() { var id1 = new TurkishIdNumber(validTurkishId); var id2 = new TurkishIdNumber(validTurkishId); Assert.IsTrue(id1.Equals(id2)); }
void Equals_NullTarget_ReturnsFalse() { var id1 = new TurkishIdNumber(validNumbers[0]); TurkishIdNumber id2 = null; Assert.IsFalse(id1.Equals(id2)); }
void Equals_DifferentValues_ReturnsFalse() { var id1 = new TurkishIdNumber(validNumbers[0]); var id2 = new TurkishIdNumber(validNumbers[1]); Assert.IsFalse(id1.Equals(id2)); }
void ctor_Valid_SetsValueSuccessfully() { var result = new TurkishIdNumber(validTurkishId); Assert.AreEqual(validTurkishId, result.Value); Assert.AreEqual(validTurkishId, result.ToString()); }
void ctor_NumericValue_ReturnCorrectsValue() { var id = new TurkishIdNumber(long.Parse(validTurkishId)); Assert.AreEqual(validTurkishId, id.Value); }