[bcl] Remove more NET_2_0 checks from class libs
[mono.git] / mcs / class / System / Test / System.Net.NetworkInformation / PhysicalAddressTest.cs
1 using NUnit.Framework;
2 using System;
3 using System.Net.NetworkInformation;
4
5 namespace MonoTests.System.Net.NetworkInformation
6 {
7         [TestFixture]
8         public class PhysicalAddressTest
9         {
10                 [Test] 
11                 public void CreateNormal()
12                 {
13                         // Normal case, creation of physical address
14                         PhysicalAddress phys = new PhysicalAddress(new byte [] { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06 });
15                 }
16
17                 [Test]
18                 public void CreateWithLarger()
19                 {
20                         // MS.NET 2.0 Allows Physical Address to be created if array larger than normal
21                         PhysicalAddress phys = new PhysicalAddress(new byte [] { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06 });
22                 }
23
24                 [Test]
25                 public void CreateWithSmaller()
26                 {
27                         // MS.NET 2.0 Allows Physical Address to be created if array smaller than normal
28                         PhysicalAddress phys = new PhysicalAddress(new byte [] { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06 });
29                 }
30
31                 [Test]
32                 public void ParseNull()
33                 {
34                         // MS.NET 2.0 returns empty PhysicalAddress when passed null
35                         PhysicalAddress phys = PhysicalAddress.Parse(null);
36                         Assert.AreEqual(0, phys.GetAddressBytes().Length);
37                 }
38
39                 [Test]
40                 [ExpectedException(typeof(FormatException))]
41                 public void ParseEmpty()
42                 {
43                         // MS.NET 2.0 Fails parse when empty
44                         PhysicalAddress phys = PhysicalAddress.Parse("");
45                 }
46
47                 [Test]
48                 public void ParseWithoutDash()
49                 {
50                         // MS.NET 2.0 Parses without the dash separator
51                         PhysicalAddress phys = PhysicalAddress.Parse("010203040506");
52                 }
53
54                 [Test]
55                 [ExpectedException(typeof(FormatException))]
56                 public void ParseWithoutDashToFewChars()
57                 {
58                         // MS.NET 2.0 Fails parse when too few characters
59                         PhysicalAddress phys = PhysicalAddress.Parse("01020304050");
60                 }
61
62                 [Test]
63                 [ExpectedException(typeof(FormatException))]
64                 public void ParseWithoutDashToManyChars()
65                 {
66                         // MS.NET 2.0 Fails parse when too many characters
67                         PhysicalAddress phys = PhysicalAddress.Parse("0102030405060");
68                 }
69
70                 [Test]
71                 public void ParseWithDash()
72                 {
73                         PhysicalAddress phys = PhysicalAddress.Parse("01-02-03-04-05-06");
74                 }
75
76                 [Test]
77                 [ExpectedException(typeof(IndexOutOfRangeException))]
78                 public void ParseWithDashToFewChars()
79                 {
80                         PhysicalAddress phys = PhysicalAddress.Parse("01-02-03-04-05-0");
81                 }
82
83                 [Test]
84                 [ExpectedException(typeof(FormatException))]
85                 public void ParseWithDashToManyChars()
86                 {
87                         PhysicalAddress phys = PhysicalAddress.Parse("01-02-03-04-05-060");
88                 }
89
90                 [Test]
91                 public void GetHashCodeEqual()
92                 {
93                         PhysicalAddress phys1 = new PhysicalAddress(new byte[] { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06 });
94                         PhysicalAddress phys2 = new PhysicalAddress(new byte[] { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06 });
95
96                         Assert.AreEqual(phys1.GetHashCode(), phys2.GetHashCode());
97                 }
98
99                 [Test]
100                 public void GetHashCodeNotEqual()
101                 {
102                         PhysicalAddress phys1 = new PhysicalAddress(new byte[] { 0x06, 0x05, 0x04, 0x03, 0x02, 0x01 });
103                         PhysicalAddress phys2 = new PhysicalAddress(new byte[] { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06 });
104
105                         Assert.IsFalse(phys1.GetHashCode().Equals(phys2.GetHashCode()));
106                 }
107
108                 [Test]
109                 public void ToStringTest()
110                 {
111                         PhysicalAddress phys1 = new PhysicalAddress(new byte[] { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06 });
112                         Assert.AreEqual("010203040506", phys1.ToString());
113                 }
114
115                 [Test]
116                 public void EqualsNormal()
117                 {
118                         PhysicalAddress phys1 = new PhysicalAddress(new byte[] { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06 });
119                         PhysicalAddress phys2 = new PhysicalAddress(new byte[] { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06 });
120
121                         Assert.IsTrue(phys1.Equals(phys2));
122                 }
123
124                 [Test]
125                 public void EqualsNot()
126                 {
127                         PhysicalAddress phys1 = new PhysicalAddress(new byte[] { 0x06, 0x5, 0x04, 0x03, 0x02, 0x01 });
128                         PhysicalAddress phys2 = new PhysicalAddress(new byte[] { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06 });
129
130                         Assert.IsTrue(!phys1.Equals(phys2));
131                 }
132         }
133 }
134