1 | '--------------------------------------------------------------------
|
---|
2 | ' Test case of Version Class
|
---|
3 | '--------------------------------------------------------------------
|
---|
4 |
|
---|
5 | Namespace VersionTest
|
---|
6 |
|
---|
7 | Sub TestMain()
|
---|
8 | Dim v12 = New System.Version(1, 2)
|
---|
9 | Dim v123 = New System.Version(1, 2, 3)
|
---|
10 | Dim v1234 = New System.Version(1, 2, 3, 4)
|
---|
11 |
|
---|
12 | UnitTest("Version(major, minor)", String.Compare(v12.ToString(), "1.2") = 0)
|
---|
13 | UnitTest("Version(major, minor, build)", String.Compare(v123.ToString(), "1.2.3") = 0)
|
---|
14 | UnitTest("Version(major, minor, build, revision)", String.Compare(v1234.ToString(), "1.2.3.4") = 0)
|
---|
15 |
|
---|
16 | UnitTest("Version.ToString(0)", String.Compare(v1234.ToString(0), "") = 0)
|
---|
17 | UnitTest("Version.ToString(1)", String.Compare(v1234.ToString(1), "1") = 0)
|
---|
18 | UnitTest("Version.ToString(2)", String.Compare(v1234.ToString(2), "1.2") = 0)
|
---|
19 | UnitTest("Version.ToString(3)", String.Compare(v1234.ToString(3), "1.2.3") = 0)
|
---|
20 | UnitTest("Version.ToString(4)", String.Compare(v1234.ToString(4), "1.2.3.4") = 0)
|
---|
21 |
|
---|
22 | UnitTest("Version.Major", v1234.Major = 1)
|
---|
23 | UnitTest("Version.Minor", v1234.Minor = 2)
|
---|
24 | UnitTest("Version.Build", v1234.Build = 3)
|
---|
25 | UnitTest("Version.Revision", v1234.Revision = 4)
|
---|
26 |
|
---|
27 | Dim v120 = New System.Version(1, 2, 0)
|
---|
28 | Dim v1231 = New System.Version(1, 2, 3, 1)
|
---|
29 | Dim v131 = New System.Version(1, 3, 1)
|
---|
30 | Dim v20 = New System.Version(2, 0)
|
---|
31 |
|
---|
32 | UnitTest("Version (1.3.1).CompareTo(2.0) < 0", v131.CompareTo(v20) < 0)
|
---|
33 | UnitTest("Version (1.3.1).CompareTo(1.3.1) = 0", v131.CompareTo(v131) = 0)
|
---|
34 | UnitTest("Version (1.3.1).CompareTo(1.2.3.4) > 0", v131.CompareTo(v1234) > 0)
|
---|
35 |
|
---|
36 | UnitTest("Version (2.0).Equals(2.0)", v20.Equals(v20))
|
---|
37 | UnitTest("Version Not (2.0).Equals(1.2)", Not v20.Equals(v12))
|
---|
38 |
|
---|
39 | UnitTest("Version - 1.2.3.4 = 1.2.3.4", v1234 = v1234)
|
---|
40 | UnitTest("Version - Not 1.2.3.4 = 1.2.3", Not v1234 = v123)
|
---|
41 | UnitTest("Version - 1.2.3.4 <> 2.0", v1234 <> v20)
|
---|
42 | UnitTest("Version - Not 1.2.3.4 <> 1.2.3.4", v1234 <> v123)
|
---|
43 | UnitTest("Version - 1.2.3.4 > 1.2.3", v1234 > v123)
|
---|
44 | UnitTest("Version - 1.2.3.4 > 1.2", v1234 > v12)
|
---|
45 | UnitTest("Version - 1.3.1 > 1.2", v131 > v12)
|
---|
46 | UnitTest("Version - 1.2.0 > 1.2", v120 > v12)
|
---|
47 | UnitTest("Version - 1.2.3.4 > 1.2.3.1", v1234 > v1231)
|
---|
48 | UnitTest("Version - 1.2 < 1.2.0", v12 < v120)
|
---|
49 | UnitTest("Version - Not 1.2 > 1.2.0", Not v12 > v120)
|
---|
50 | UnitTest("Version - 1.2.3.4 => 1.2.3", v1234 => v123)
|
---|
51 | UnitTest("Version - 1.2.3.4 => 1.2.3.4", v1234 => v1234)
|
---|
52 | UnitTest("Version - Not 1.2.3.4 =< 1.2.3", Not v1234 =< v123)
|
---|
53 | UnitTest("Version - 1.2.3.4 =< 1.2.3.4", v1234 =< v1234)
|
---|
54 | End Sub
|
---|
55 |
|
---|
56 | End Namespace
|
---|
57 |
|
---|
58 | VersionTest.TestMain()
|
---|