public void WhenPassAStringDateCanConvertToDate() { const string stringToConvert = "251190"; var canConvertToDate = _dateUtilService.CanConvertToDate(stringToConvert); Assert.IsTrue(canConvertToDate); }
public ValidationType Validate(string word) { var regex = new Regex("[0-9]{6,8}"); if (!regex.Match(word).Success) { return(ValidationType.Strong); } var startIndex = regex.Match(word).Index; String dateWord; try { dateWord = word.Substring(startIndex, 8); } catch (Exception) { dateWord = word.Substring(startIndex, 6); } if (_dateUtilService.CanConvertToDate(dateWord)) { return(ValidationType.Weak); } return(ValidationType.Strong); }