diff ServerMonitorTest/ScheduleTest.cs @ 0:3e1a2131f897

Initial commit. Ping check, scheduling, UI working. SSH check mostly working.
author Brad Greco <brad@bgreco.net>
date Mon, 31 Dec 2018 18:32:14 -0500
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ServerMonitorTest/ScheduleTest.cs	Mon Dec 31 18:32:14 2018 -0500
@@ -0,0 +1,118 @@
+using System;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+using ServerMonitorApp;
+
+namespace ServerMonitorTest
+{
+    [TestClass]
+    public class ScheduleTest
+    {
+        private Schedule secondAllDaySchedule = new Schedule(FrequencyUnits.Second, 5, new TimeSpan(0, 0, 0), new TimeSpan(23, 59, 59));
+        private Schedule secondPartDaySchedule = new Schedule(FrequencyUnits.Second, 5, new TimeSpan(10, 0, 0), new TimeSpan(21, 0, 0));
+        private Schedule secondSpanDaySchedule = new Schedule(FrequencyUnits.Second, 5, new TimeSpan(21, 0, 0), new TimeSpan(10, 0, 0));
+
+        #region All day
+
+        [TestMethod]
+        public void TestAllDay1()
+        {
+            Assert.AreEqual(new DateTime(2000, 1, 1, 1, 0, 5),
+                secondAllDaySchedule.GetNextTime(new DateTime(2000, 1, 1, 1, 0, 0), new DateTime(2000, 1, 1, 1, 0, 1)));
+        }
+
+        [TestMethod]
+        public void TestAllDay2()
+        {
+            Assert.AreEqual(new DateTime(2000, 1, 1, 1, 0, 15),
+                secondAllDaySchedule.GetNextTime(new DateTime(2000, 1, 1, 1, 0, 0), new DateTime(2000, 1, 1, 1, 0, 11)));
+        }
+
+        [TestMethod]
+        public void TestAllDay3()
+        {
+            Assert.AreEqual(new DateTime(2000, 1, 1, 2, 0, 15),
+                secondAllDaySchedule.GetNextTime(new DateTime(2000, 1, 1, 1, 0, 0), new DateTime(2000, 1, 1, 2, 0, 11)));
+        }
+
+        [TestMethod]
+        public void TestAllDay4()
+        {
+            Assert.AreEqual(new DateTime(2000, 1, 2, 0, 0, 3),
+                secondAllDaySchedule.GetNextTime(new DateTime(2000, 1, 1, 23, 59, 58), new DateTime(2000, 1, 1, 23, 59, 59)));
+        }
+
+        [TestMethod]
+        public void TestAllDay5()
+        {
+            Assert.AreEqual(new DateTime(2000, 1, 2, 0, 0, 8),
+                secondAllDaySchedule.GetNextTime(new DateTime(2000, 1, 1, 23, 59, 58), new DateTime(2000, 1, 2, 0, 0, 4)));
+        }
+
+        #endregion
+
+        #region Part day
+
+        [TestMethod]
+        public void TestPartDay1()
+        {
+            Assert.AreEqual(new DateTime(2000, 1, 1, 10, 0, 5),
+                secondPartDaySchedule.GetNextTime(new DateTime(2000, 1, 1, 10, 0, 0), new DateTime(2000, 1, 1, 10, 0, 1)));
+        }
+
+        [TestMethod]
+        public void TestPartDay2()
+        {
+            Assert.AreEqual(new DateTime(2000, 1, 2, 10, 0, 0),
+                secondPartDaySchedule.GetNextTime(new DateTime(2000, 1, 1, 10, 0, 3), new DateTime(2000, 1, 1, 20, 59, 59)));
+        }
+
+        [TestMethod]
+        public void TestPartDay3()
+        {
+            Assert.AreEqual(new DateTime(2000, 1, 2, 10, 0, 0),
+                secondPartDaySchedule.GetNextTime(new DateTime(2000, 1, 1, 10, 0, 3), new DateTime(2000, 1, 1, 21, 0, 0)));
+        }
+
+        #endregion
+
+        #region Span day
+
+        [TestMethod]
+        public void TestSpanDay1()
+        {
+            Assert.AreEqual(new DateTime(2000, 1, 1, 1, 0, 5),
+                secondSpanDaySchedule.GetNextTime(new DateTime(2000, 1, 1, 1, 0, 0), new DateTime(2000, 1, 1, 1, 0, 1)));
+        }
+
+        [TestMethod]
+        public void TestSpanDay2()
+        {
+            Assert.AreEqual(new DateTime(2000, 1, 2, 0, 0, 3),
+                secondSpanDaySchedule.GetNextTime(new DateTime(2000, 1, 1, 23, 59, 58), new DateTime(2000, 1, 1, 23, 59, 59)));
+        }
+
+        [TestMethod]
+        public void TestSpanDay3()
+        {
+            Assert.AreEqual(new DateTime(2000, 1, 2, 0, 0, 8),
+                secondSpanDaySchedule.GetNextTime(new DateTime(2000, 1, 1, 23, 59, 58), new DateTime(2000, 1, 2, 0, 0, 4)));
+        }
+
+        [TestMethod]
+        public void TestSpanDay4()
+        {
+            Assert.AreEqual(new DateTime(2000, 1, 2, 21, 0, 0),
+                secondSpanDaySchedule.GetNextTime(new DateTime(2000, 1, 1, 21, 0, 8), new DateTime(2000, 1, 2, 9, 59, 59)));
+        }
+
+        [TestMethod]
+        public void TestSpanDay5()
+        {
+            Assert.AreEqual(new DateTime(2000, 1, 2, 21, 0, 0),
+                secondSpanDaySchedule.GetNextTime(new DateTime(2000, 1, 1, 21, 0, 8), new DateTime(2000, 1, 2, 11, 0, 0)));
+        }
+
+        #endregion
+
+    }
+}