Пример #1
0
        static void Main(string[] args)
        {
            Initialize();
            Console.ReadKey();
            Console.WriteLine();

            do
            {
                InitializeHeader();

                DateTime dateTime1 = ReadDateFromConsole();
                ConsoleManager.Header.Replace("1) __ . __ . ____", "1) " + dateTime1.ToShortDateString());
                DateTime dateTime2 = ReadDateFromConsole();
                ConsoleManager.Header.Replace("2) __ . __ . ____", "2) " + dateTime2.ToShortDateString());

                ConsoleManager.RefreshHeader();

                DateTimeManager.RevertDatesIfNeeded(ref dateTime1, ref dateTime2);

                ConsoleManager.Write("The necessary data has been entered. Click any key to calculate...");
                Console.ReadKey();
                ConsoleManager.Write("Calculation...");
                Thread.Sleep(1000);

                ConsoleManager.Header.Replace("______ - ______", DateTimeManager.CalculateDates(dateTime1, dateTime2));
                ConsoleManager.Write("DONE! Click escape to stop...");
            }while (Console.ReadKey(true).Key != ConsoleKey.Escape);
        }
Пример #2
0
        public void CalculateDates_CompletelyDifferentDates_DisplayInFull()
        {
            DateTime date1 = new DateTime(1999, 1, 10);
            DateTime date2 = new DateTime(2011, 12, 25);

            string value = DateTimeManager.CalculateDates(date1, date2);

            string expected = "10.01.1999 - 25.12.2011";

            Assert.AreEqual(value, expected);
        }
Пример #3
0
        public void CalculateDates_SameYearAndMonth_CutYearAndMonth()
        {
            DateTime date1 = new DateTime(1994, 2, 5);
            DateTime date2 = new DateTime(1994, 2, 8);

            string value = DateTimeManager.CalculateDates(date1, date2);

            string expected = "05 - 08.02.1994";

            Assert.AreEqual(value, expected);
        }
Пример #4
0
        public void CalculateDates_SameYear_CutYear()
        {
            DateTime date1 = new DateTime(2000, 10, 1);
            DateTime date2 = new DateTime(2000, 12, 20);

            string value = DateTimeManager.CalculateDates(date1, date2);

            string expected = "01.10 - 20.12.2000";

            Assert.AreEqual(value, expected);
        }