2009-07-11 Michael Barker <mike@middlesoft.co.uk>
[mono.git] / mcs / class / corlib / Test / System / ValueTypeTest.cs
1 //
2 // VersionTest.cs - NUnit Test Cases for the System.ValueType class
3 //
4 // Authors:
5 //      Gonzalo Paniagua Javier (gonzalo@ximian.com)
6 //
7 // (c) 2003 Novell, Inc. (http://www.novell.com)
8 //
9
10 using NUnit.Framework;
11 using System;
12
13 namespace MonoTests.System
14 {
15         struct Blah
16         { 
17                 public string s;
18                 public int x;
19
20                 public Blah (string s, int x)
21                 {
22                         this.s = s;
23                         this.x = x;
24                 }
25         }
26
27         struct Lalala
28         { 
29                 public int x;
30                 public string s;
31
32                 public Lalala (string s, int x)
33                 {
34                         this.s = s;
35                         this.x = x;
36                 }
37         }
38
39         [TestFixture]
40         public class ValueTypeTest 
41         {
42                 [Test]
43                 public void TestEquals ()
44                 {
45                         Blah a = new Blah ("abc", 1);
46                         Blah b = new Blah (string.Format ("ab{0}", 'c'), 1);
47                         Assert.AreEqual (a.Equals (b), true, "#01");
48                 }
49
50                 [Test]
51                 public void TestGetHash ()
52                 {
53                         Blah a = new Blah ("abc", 1);
54                         Blah b = new Blah (string.Format ("ab{0}", 'c'), 1);
55                         Assert.AreEqual (a.GetHashCode (), b.GetHashCode (), "#01");
56
57                         Lalala la = new Lalala ("abc", 1);
58                         Lalala lb = new Lalala (string.Format ("ab{0}", 'c'), 1);
59                         Assert.AreEqual (la.GetHashCode (), lb.GetHashCode (), "#02");
60
61                         a = new Blah (null, 1);
62                         b = new Blah (null, 1);
63                         Assert.AreEqual (la.GetHashCode (), lb.GetHashCode (), "#03");
64
65                         la = new Lalala (null, 1);
66                         lb = new Lalala (null, 1);
67                         Assert.AreEqual (la.GetHashCode (), lb.GetHashCode (), "#04");
68                 }
69         }
70 }
71