public void TryParse_NonStringValue_ExceptionIsThrown() { var value = 20000101; var format = "yyyyMMdd"; var bitAttribute = new DateTimeAttribute(format); var couldParse = bitAttribute.TryParse(null, value, out object parsedFieldValue, out string failureMessage); }
public void TryParse_ValidDate_CouldParse() { var value = "20000101"; var format = "yyyyMMdd"; var bitAttribute = new DateTimeAttribute(format); var couldParse = bitAttribute.TryParse(null, value, out object parsedFieldValue, out string failureMessage); Assert.IsTrue(couldParse); Assert.AreEqual(DateTime.Parse("2000-01-01"), (DateTime)parsedFieldValue); Assert.IsNull(failureMessage); }
public void TryParse_InvalidDate_CouldNotParse() { var value = "invalid"; var format = "yyyyMMdd"; var bitAttribute = new DateTimeAttribute(format); var couldParse = bitAttribute.TryParse(null, value, out object parsedFieldValue, out string failureMessage); Assert.IsFalse(couldParse); Assert.IsNull(parsedFieldValue); Assert.IsFalse(String.IsNullOrEmpty(failureMessage)); }