Projekt

Obecné

Profil

Stáhnout (2.5 KB) Statistiky
| Větev: | Tag: | Revize:
1
using Microsoft.VisualStudio.TestTools.UnitTesting;
2
using ServerApp.DataDownload;
3
using System;
4
using System.Collections.Generic;
5
using System.Linq;
6
using System.Text;
7
using System.Threading.Tasks;
8

    
9
namespace ServerAppFunctionalTests.DownloaderTests
10
{
11
	[TestClass]
12
	public class DateTesting
13
	{
14
		[TestMethod]
15
		[ExpectedException(typeof(ArgumentOutOfRangeException))]
16
		public void DateInvalidMonthZero()
17
		{
18
			Date d = new Date(0, 2019);
19
		}
20

    
21
		[TestMethod]
22
		[ExpectedException(typeof(ArgumentOutOfRangeException))]
23
		public void DateInvalidMonthOver12()
24
		{
25
			Date d = new Date(13, 2019);
26
		}
27

    
28
		[TestMethod]
29
		public void DatesEqual()
30
		{
31
			Date d1 = new Date(2, 2019);
32
			Date d2 = new Date(2, 2019);
33

    
34
			bool datesEqual = d1.Equals(d2) && d2.Equals(d1);
35
			Assert.IsTrue(datesEqual);
36
		}
37

    
38
		[TestMethod]
39
		public void DatesNotEqual()
40
		{
41
			Date d1 = new Date(2, 2019);
42
			Date d2 = new Date(3, 2019);
43

    
44
			bool datesEqual = d1.Equals(d2) || d2.Equals(d1);
45
			Assert.IsFalse(datesEqual);
46
		}
47

    
48
		[TestMethod]
49
		public void DateSmaller()
50
		{
51
			Date d2_19 = new Date(2, 2019);
52
			Date d3_19 = new Date(3, 2019);
53
			Date d10_18 = new Date(10, 2018);
54
			Date d1_20 = new Date(1, 2020);
55

    
56
			bool smaller = 
57
				d2_19 < d3_19 && 
58
				d3_19 < d1_20 && 
59
				d10_18 < d2_19;
60

    
61
			Assert.IsTrue(smaller);
62
		}
63

    
64
		[TestMethod]
65
		public void DateSmallerOrEqual()
66
		{
67
			Date d1 = new Date(8, 2017);
68
			Date d2 = new Date(8, 2017);
69
			Date d3 = new Date(12, 2017);
70

    
71
			bool lessOrEqual = d1 <= d2 && d2 <= d3;
72

    
73
			Assert.IsTrue(lessOrEqual);
74
		}
75

    
76
		[TestMethod]
77
		public void DateGreater()
78
		{
79
			Date d2_19 = new Date(2, 2019);
80
			Date d3_19 = new Date(3, 2019);
81
			Date d10_18 = new Date(10, 2018);
82
			Date d1_20 = new Date(1, 2020);
83

    
84
			bool greater =
85
				 d3_19 > d2_19 &&
86
				d1_20 > d3_19 &&
87
				d2_19 > d10_18;
88

    
89
			Assert.IsTrue(greater);
90
		}
91

    
92
		[TestMethod]
93
		public void DateGreaterOrEqual()
94
		{
95
			Date d1 = new Date(8, 2017);
96
			Date d2 = new Date(8, 2017);
97
			Date d3 = new Date(12, 2017);
98

    
99
			bool greaterOrEqual = d1 >= d2 && d3 >= d2;
100

    
101
			Assert.IsTrue(greaterOrEqual);
102
		}
103

    
104
		[TestMethod]
105
		public void MonthIncreased()
106
		{
107
			Date d = new Date(3, 2010);
108
			Date dIncreased = d.IncreaseMonthByOne();
109

    
110
			Assert.AreEqual((uint)4, dIncreased.Month);
111
			Assert.AreEqual((uint)2010, dIncreased.Year);
112
		}
113

    
114
		[TestMethod]
115
		public void MonthIncreasedYrBreak()
116
		{
117
			Date d = new Date(12, 2010);
118
			Date dIncreased = d.IncreaseMonthByOne();
119

    
120
			Assert.AreEqual((uint)1, dIncreased.Month);
121
			Assert.AreEqual((uint)2011, dIncreased.Year);
122
		}
123

    
124
	}
125
}
(2-2/2)