comparison 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
comparison
equal deleted inserted replaced
-1:000000000000 0:3e1a2131f897
1 using System;
2 using Microsoft.VisualStudio.TestTools.UnitTesting;
3 using ServerMonitorApp;
4
5 namespace ServerMonitorTest
6 {
7 [TestClass]
8 public class ScheduleTest
9 {
10 private Schedule secondAllDaySchedule = new Schedule(FrequencyUnits.Second, 5, new TimeSpan(0, 0, 0), new TimeSpan(23, 59, 59));
11 private Schedule secondPartDaySchedule = new Schedule(FrequencyUnits.Second, 5, new TimeSpan(10, 0, 0), new TimeSpan(21, 0, 0));
12 private Schedule secondSpanDaySchedule = new Schedule(FrequencyUnits.Second, 5, new TimeSpan(21, 0, 0), new TimeSpan(10, 0, 0));
13
14 #region All day
15
16 [TestMethod]
17 public void TestAllDay1()
18 {
19 Assert.AreEqual(new DateTime(2000, 1, 1, 1, 0, 5),
20 secondAllDaySchedule.GetNextTime(new DateTime(2000, 1, 1, 1, 0, 0), new DateTime(2000, 1, 1, 1, 0, 1)));
21 }
22
23 [TestMethod]
24 public void TestAllDay2()
25 {
26 Assert.AreEqual(new DateTime(2000, 1, 1, 1, 0, 15),
27 secondAllDaySchedule.GetNextTime(new DateTime(2000, 1, 1, 1, 0, 0), new DateTime(2000, 1, 1, 1, 0, 11)));
28 }
29
30 [TestMethod]
31 public void TestAllDay3()
32 {
33 Assert.AreEqual(new DateTime(2000, 1, 1, 2, 0, 15),
34 secondAllDaySchedule.GetNextTime(new DateTime(2000, 1, 1, 1, 0, 0), new DateTime(2000, 1, 1, 2, 0, 11)));
35 }
36
37 [TestMethod]
38 public void TestAllDay4()
39 {
40 Assert.AreEqual(new DateTime(2000, 1, 2, 0, 0, 3),
41 secondAllDaySchedule.GetNextTime(new DateTime(2000, 1, 1, 23, 59, 58), new DateTime(2000, 1, 1, 23, 59, 59)));
42 }
43
44 [TestMethod]
45 public void TestAllDay5()
46 {
47 Assert.AreEqual(new DateTime(2000, 1, 2, 0, 0, 8),
48 secondAllDaySchedule.GetNextTime(new DateTime(2000, 1, 1, 23, 59, 58), new DateTime(2000, 1, 2, 0, 0, 4)));
49 }
50
51 #endregion
52
53 #region Part day
54
55 [TestMethod]
56 public void TestPartDay1()
57 {
58 Assert.AreEqual(new DateTime(2000, 1, 1, 10, 0, 5),
59 secondPartDaySchedule.GetNextTime(new DateTime(2000, 1, 1, 10, 0, 0), new DateTime(2000, 1, 1, 10, 0, 1)));
60 }
61
62 [TestMethod]
63 public void TestPartDay2()
64 {
65 Assert.AreEqual(new DateTime(2000, 1, 2, 10, 0, 0),
66 secondPartDaySchedule.GetNextTime(new DateTime(2000, 1, 1, 10, 0, 3), new DateTime(2000, 1, 1, 20, 59, 59)));
67 }
68
69 [TestMethod]
70 public void TestPartDay3()
71 {
72 Assert.AreEqual(new DateTime(2000, 1, 2, 10, 0, 0),
73 secondPartDaySchedule.GetNextTime(new DateTime(2000, 1, 1, 10, 0, 3), new DateTime(2000, 1, 1, 21, 0, 0)));
74 }
75
76 #endregion
77
78 #region Span day
79
80 [TestMethod]
81 public void TestSpanDay1()
82 {
83 Assert.AreEqual(new DateTime(2000, 1, 1, 1, 0, 5),
84 secondSpanDaySchedule.GetNextTime(new DateTime(2000, 1, 1, 1, 0, 0), new DateTime(2000, 1, 1, 1, 0, 1)));
85 }
86
87 [TestMethod]
88 public void TestSpanDay2()
89 {
90 Assert.AreEqual(new DateTime(2000, 1, 2, 0, 0, 3),
91 secondSpanDaySchedule.GetNextTime(new DateTime(2000, 1, 1, 23, 59, 58), new DateTime(2000, 1, 1, 23, 59, 59)));
92 }
93
94 [TestMethod]
95 public void TestSpanDay3()
96 {
97 Assert.AreEqual(new DateTime(2000, 1, 2, 0, 0, 8),
98 secondSpanDaySchedule.GetNextTime(new DateTime(2000, 1, 1, 23, 59, 58), new DateTime(2000, 1, 2, 0, 0, 4)));
99 }
100
101 [TestMethod]
102 public void TestSpanDay4()
103 {
104 Assert.AreEqual(new DateTime(2000, 1, 2, 21, 0, 0),
105 secondSpanDaySchedule.GetNextTime(new DateTime(2000, 1, 1, 21, 0, 8), new DateTime(2000, 1, 2, 9, 59, 59)));
106 }
107
108 [TestMethod]
109 public void TestSpanDay5()
110 {
111 Assert.AreEqual(new DateTime(2000, 1, 2, 21, 0, 0),
112 secondSpanDaySchedule.GetNextTime(new DateTime(2000, 1, 1, 21, 0, 8), new DateTime(2000, 1, 2, 11, 0, 0)));
113 }
114
115 #endregion
116
117 }
118 }