Projekt

Obecné

Profil

Stáhnout (7.55 KB) Statistiky
| Větev: | Tag: | Revize:
1 a53b1de8 A-Konig
using Microsoft.VisualStudio.TestTools.UnitTesting;
2
using System;
3
using ServerApp.Parser.Parsers;
4
using System.Collections.Generic;
5
using ServerApp.Parser.OutputInfo;
6
7 8a243ab2 A-Konig
namespace TestProject.ParserTests
8 a53b1de8 A-Konig
{
9
10
    [TestClass]
11
    public class TestingParser
12
    {
13
        [TestMethod]
14
        public void AbstactClassTest()
15
        {
16
            IDataParser p = new DataParser(null);
17
            List<ActivityInfo> aa = p.AttendanceList;
18
            List<WeatherInfo> wa = p.WeatherList;
19
20
            DataParser pp = (DataParser)p;
21
            List<ActivityInfo> ap = pp.AttendanceList;
22
            List<WeatherInfo> wp = pp.WeatherList;
23
24
            Assert.AreEqual(aa, ap);
25
            Assert.AreEqual(wa, wp);
26
        }
27
28
        // ------------------------------------ MERGE LISTS -------------------------------------
29
30
        #region Merge lists
31
        [TestMethod]
32
        public void MergeListsNull()
33
        {
34
            DataParser target = new DataParser(null);
35
            PrivateObject obj = new PrivateObject(target);
36
37
            List<ActivityInfo> jis = null;
38
            List<ActivityInfo> pc = null;
39
40
            List<ActivityInfo> retVal = (List<ActivityInfo>)obj.Invoke("MergeAttendance", jis, pc);
41
            Assert.AreEqual(0, retVal.Count);
42
        }
43
44
        [TestMethod]
45
        public void MergeListsJisNull()
46
        {
47
            DataParser target = new DataParser(null);
48
            PrivateObject obj = new PrivateObject(target);
49
50
            List<ActivityInfo> jis = null;
51
            List<ActivityInfo> pc = new List<ActivityInfo>();
52
53
            List<ActivityInfo> retVal = (List<ActivityInfo>)obj.Invoke("MergeAttendance", jis, pc);
54
            Assert.AreEqual(pc, retVal);
55
        }
56
57
        [TestMethod]
58
        public void MergeListsPcNull()
59
        {
60
            DataParser target = new DataParser(null);
61
            PrivateObject obj = new PrivateObject(target);
62
63
            List<ActivityInfo> jis = new List<ActivityInfo>();
64
            List<ActivityInfo> pc = null;
65
66
            List<ActivityInfo> retVal = (List<ActivityInfo>)obj.Invoke("MergeAttendance", jis, pc);
67
            Assert.AreEqual(jis, retVal);
68
        }
69
70
        [TestMethod]
71
        public void MergeListsOneNoOverlap()
72
        {
73
            DataParser target = new DataParser(null);
74
            PrivateObject obj = new PrivateObject(target);
75
76
            List<ActivityInfo> jis = new List<ActivityInfo>();
77
            List<ActivityInfo> pc = new List<ActivityInfo>();
78
79
            jis.Add(new ActivityInfo("FAV", 5, new DateTime(2001, 1, 1, 15, 0, 0), 3));
80
            pc.Add(new ActivityInfo("FAV", 3, new DateTime(2001, 1, 1, 18, 0, 0), 3));
81
82
            List<ActivityInfo> retVal = (List<ActivityInfo>)obj.Invoke("MergeAttendance", jis, pc);
83
84
            Assert.AreEqual(2, retVal.Count);
85
            Assert.AreEqual(new ActivityInfo("FAV", 5, new DateTime(2001, 1, 1, 15, 0, 0), 3), retVal[0]);
86
            Assert.AreEqual(new ActivityInfo("FAV", 3, new DateTime(2001, 1, 1, 18, 0, 0), 3), retVal[1]);
87
        }
88
89
        [TestMethod]
90
        public void MergeListsOneOverlap()
91
        {
92
            DataParser target = new DataParser(null);
93
            PrivateObject obj = new PrivateObject(target);
94
95
            List<ActivityInfo> jis = new List<ActivityInfo>();
96
            List<ActivityInfo> pc = new List<ActivityInfo>();
97
98
            jis.Add(new ActivityInfo("FAV", 5, new DateTime(2001, 1, 1, 15, 0, 0), 3));
99
            pc.Add(new ActivityInfo("FAV", 3, new DateTime(2001, 1, 1, 15, 0, 0), 3));
100
101
            List<ActivityInfo> retVal = (List<ActivityInfo>)obj.Invoke("MergeAttendance", jis, pc);
102
103
            Assert.AreEqual(1, retVal.Count);
104
            Assert.AreEqual(new ActivityInfo("FAV", 8, new DateTime(2001, 1, 1, 15, 0, 0), 3), retVal[0]);
105
        }
106
107
        [TestMethod]
108
        public void MergeListsTwoNoOverlap()
109
        {
110
            DataParser target = new DataParser(null);
111
            PrivateObject obj = new PrivateObject(target);
112
113
            List<ActivityInfo> jis = new List<ActivityInfo>();
114
            List<ActivityInfo> pc = new List<ActivityInfo>();
115
116
            jis.Add(new ActivityInfo("FAV", 5, new DateTime(2001, 1, 1, 9, 0, 0), 3));
117
            jis.Add(new ActivityInfo("FAV", 1, new DateTime(2001, 1, 1, 15, 0, 0), 3));
118
            pc.Add(new ActivityInfo("FAV", 3, new DateTime(2001, 1, 1, 12, 0, 0), 3));
119
            pc.Add(new ActivityInfo("FAV", 2, new DateTime(2001, 1, 1, 18, 0, 0), 3));
120
121
            List<ActivityInfo> retVal = (List<ActivityInfo>)obj.Invoke("MergeAttendance", jis, pc);
122
123
            Assert.AreEqual(4, retVal.Count);
124
            Assert.AreEqual(new ActivityInfo("FAV", 5, new DateTime(2001, 1, 1, 9, 0, 0), 3), retVal[0]);
125
            Assert.AreEqual(new ActivityInfo("FAV", 3, new DateTime(2001, 1, 1, 12, 0, 0), 3), retVal[1]);
126
            Assert.AreEqual(new ActivityInfo("FAV", 1, new DateTime(2001, 1, 1, 15, 0, 0), 3), retVal[2]);
127
            Assert.AreEqual(new ActivityInfo("FAV", 2, new DateTime(2001, 1, 1, 18, 0, 0), 3), retVal[3]);
128
        }
129
130
        [TestMethod]
131
        public void MergeListsTwoOverlap()
132
        {
133
            DataParser target = new DataParser(null);
134
            PrivateObject obj = new PrivateObject(target);
135
136
            List<ActivityInfo> jis = new List<ActivityInfo>();
137
            List<ActivityInfo> pc = new List<ActivityInfo>();
138
139
            jis.Add(new ActivityInfo("FAV", 5, new DateTime(2001, 1, 1, 9, 0, 0), 3));
140
            jis.Add(new ActivityInfo("FAV", 1, new DateTime(2001, 1, 1, 15, 0, 0), 3));
141
            pc.Add(new ActivityInfo("FAV", 3, new DateTime(2001, 1, 1, 12, 0, 0), 3));
142
            pc.Add(new ActivityInfo("FAV", 2, new DateTime(2001, 1, 1, 15, 0, 0), 3));
143
144
            List<ActivityInfo> retVal = (List<ActivityInfo>)obj.Invoke("MergeAttendance", jis, pc);
145
146
            Assert.AreEqual(3, retVal.Count);
147
            Assert.AreEqual(new ActivityInfo("FAV", 5, new DateTime(2001, 1, 1, 9, 0, 0), 3), retVal[0]);
148
            Assert.AreEqual(new ActivityInfo("FAV", 3, new DateTime(2001, 1, 1, 12, 0, 0), 3), retVal[1]);
149
            Assert.AreEqual(new ActivityInfo("FAV", 3, new DateTime(2001, 1, 1, 15, 0, 0), 3), retVal[2]);
150
        }
151
152
        [TestMethod]
153
        public void MergeListsMultiple()
154
        {
155
            DataParser target = new DataParser(null);
156
            PrivateObject obj = new PrivateObject(target);
157
158
            List<ActivityInfo> jis = new List<ActivityInfo>();
159
            List<ActivityInfo> pc = new List<ActivityInfo>();
160
161
            jis.Add(new ActivityInfo("FAV", 5, new DateTime(2000, 1, 10, 9, 0, 0), 3));
162
            jis.Add(new ActivityInfo("FAV", 1, new DateTime(2001, 1, 1, 15, 0, 0), 3));
163
            jis.Add(new ActivityInfo("FDU", 3, new DateTime(2001, 4, 1, 15, 0, 0), 3));
164
165
            pc.Add(new ActivityInfo("FAV", 3, new DateTime(2001, 1, 1, 12, 0, 0), 3));
166
            pc.Add(new ActivityInfo("FAV", 2, new DateTime(2001, 1, 1, 15, 0, 0), 3));
167
            pc.Add(new ActivityInfo("FAV", 5, new DateTime(2001, 4, 1, 15, 0, 0), 3));
168
169
            List<ActivityInfo> retVal = (List<ActivityInfo>)obj.Invoke("MergeAttendance", jis, pc);
170
171
            Assert.AreEqual(5, retVal.Count);
172
            Assert.AreEqual(new ActivityInfo("FAV", 5, new DateTime(2000, 1, 10, 9, 0, 0), 3), retVal[0]);
173
            Assert.AreEqual(new ActivityInfo("FAV", 3, new DateTime(2001, 1, 1, 12, 0, 0), 3), retVal[1]);
174
            Assert.AreEqual(new ActivityInfo("FAV", 3, new DateTime(2001, 1, 1, 15, 0, 0), 3), retVal[2]);
175
            Assert.AreEqual(new ActivityInfo("FDU", 3, new DateTime(2001, 4, 1, 15, 0, 0), 3), retVal[3]);
176
            Assert.AreEqual(new ActivityInfo("FAV", 5, new DateTime(2001, 4, 1, 15, 0, 0), 3), retVal[4]);
177
        }
178
        #endregion
179
180
    }
181
}