static void Main(string[] args) { RawDate rawDate = new RawDate(); while (true) { Console.WriteLine("--> Please enter a date with the format DD/MM/YYYY"); string date = Console.ReadLine(); bool isValidDate = rawDate.IsDateValid(date); if (isValidDate) { Console.WriteLine("You entered the date: " + date); Console.WriteLine(); Console.WriteLine("--> Please enter the amount of days to add"); string daysToAdd = Console.ReadLine(); int i; if (int.TryParse(daysToAdd, out i)) { if (i < 1) { Console.WriteLine("XXX INVALID NUMBER OF DAYS XXX"); continue; } rawDate = new RawDate() { rawDate = date }; DateCalculator dateCalculator = new DateCalculator(); RawDate result = dateCalculator.AddDays(rawDate, int.Parse(daysToAdd)); Console.WriteLine("New Date: " + result.rawDate); } else { Console.WriteLine("XXX INVALID NUMBER OF DAYS XXX"); } Console.WriteLine(); } else { Console.WriteLine("XXX INVALID DATE XXX"); } Console.WriteLine("----------------------"); Console.WriteLine(); } }
public void AddDays_RawDate_rawDate_IsStringEmpty() { DateCalculator dateCalculator = new DateCalculator(); RawDate rawDate = new RawDate() { rawDate = "" }; RawDate returnedRawDate = dateCalculator.AddDays(rawDate, 0); Assert.IsEmpty(returnedRawDate.rawDate); }
public void AddDays_RawDateNotNull() { DateCalculator dateCalculator = new DateCalculator(); RawDate rawDate = new RawDate() { rawDate = "" }; RawDate returnedRawDate = dateCalculator.AddDays(rawDate, 0); Assert.IsNotNull(returnedRawDate); }
public void AddDays_10101972_Minus1_RawDateNull() { DateCalculator dateCalculator = new DateCalculator(); RawDate rawDate = new RawDate() { rawDate = "10/10/1972" }; RawDate result = dateCalculator.AddDays(rawDate, -1); Assert.IsNull(result.rawDate); }
public void AddDays_10101972_52_01121972() { DateCalculator dateCalculator = new DateCalculator(); RawDate rawDate = new RawDate() { rawDate = "10/10/1972" }; RawDate result = dateCalculator.AddDays(rawDate, 52); Assert.AreEqual(new RawDate() { rawDate = "01/12/1972" }.rawDate, result.rawDate); }
public void AddDays_10101972_21_31101972() { DateCalculator dateCalculator = new DateCalculator(); RawDate rawDate = new RawDate() { rawDate = "10/10/1972" }; RawDate result = dateCalculator.AddDays(rawDate, 21); Assert.AreEqual(new RawDate() { rawDate = "31/10/1972" }.rawDate, result.rawDate); }
public void AddDays_28022020_2920_26022028() { DateCalculator dateCalculator = new DateCalculator(); RawDate rawDate = new RawDate() { rawDate = "28/02/2020" }; RawDate result = dateCalculator.AddDays(rawDate, 2920); Assert.AreEqual(new RawDate() { rawDate = "26/02/2028" }.rawDate, result.rawDate); }
public void AddDays_28022020_10000_16072047() { DateCalculator dateCalculator = new DateCalculator(); RawDate rawDate = new RawDate() { rawDate = "28/02/2020" }; RawDate result = dateCalculator.AddDays(rawDate, 10000); Assert.AreEqual(new RawDate() { rawDate = "16/07/2047" }.rawDate, result.rawDate); }
public void AddDays_28022020_1461_28022024() { DateCalculator dateCalculator = new DateCalculator(); RawDate rawDate = new RawDate() { rawDate = "28/02/2020" }; RawDate result = dateCalculator.AddDays(rawDate, 1461); Assert.AreEqual(new RawDate() { rawDate = "28/02/2024" }.rawDate, result.rawDate); }
public void AddDays_28022019_1_01032019() { DateCalculator dateCalculator = new DateCalculator(); RawDate rawDate = new RawDate() { rawDate = "28/02/2019" }; RawDate result = dateCalculator.AddDays(rawDate, 1); Assert.AreEqual(new RawDate() { rawDate = "01/03/2019" }.rawDate, result.rawDate); }
public void AddDays_10101972_365_10101973() { DateCalculator dateCalculator = new DateCalculator(); RawDate rawDate = new RawDate() { rawDate = "10/10/1972" }; RawDate result = dateCalculator.AddDays(rawDate, 365); Assert.AreEqual(new RawDate() { rawDate = "10/10/1973" }.rawDate, result.rawDate); }