private static DateTime ReadDateFromConsole() { string date = null; do { if (date != null) { ConsoleManager.Write("Incorrect format!"); Console.ReadKey(); } ConsoleManager.Write("Enter a date: "); date = Console.ReadLine(); }while (!DateTimeManager.IsValidDate(date)); return(DateTime.Parse(date, new CultureInfo("pl-PL"))); }
public void IsValidDate_IncorrectFormat_False() { bool value = DateTimeManager.IsValidDate("21.20.2001"); Assert.IsFalse(value); }
public void IsValidDate_CorrectFormat_True() { bool value = DateTimeManager.IsValidDate("01.01.2012"); Assert.IsTrue(value); }