New test.
[mono.git] / mcs / class / corlib / Test / System.Collections / CaseInsensitiveComparerTest.cs
1 // CaseInsensitiveComparerTest
2
3 using System;
4 using System.Collections;
5
6 using NUnit.Framework;
7
8
9
10 namespace MonoTests.System.Collections {
11
12
13         /// <summary>CaseInsensitiveComparer test suite.</summary>
14         [TestFixture]
15         public class CaseInsensitiveComparerTest : TestCase {
16                 protected override void SetUp ()
17                 {
18                 }
19
20                 [Test]
21                 public void TestDefaultInstance ()
22                 {
23                         // Make sure the instance returned by Default
24                         // is really a CaseInsensitiveComparer.
25                         Assert((CaseInsensitiveComparer.Default
26                                 as CaseInsensitiveComparer) != null);
27                 }
28
29                 [Test]
30                 public void TestCompare () {
31                         CaseInsensitiveComparer cic = new CaseInsensitiveComparer ();
32
33                         AssertEquals(cic.Compare ("WILD WEST", "Wild West"),0);
34                         AssertEquals(cic.Compare ("WILD WEST", "wild west"),0);
35                         Assert(cic.Compare ("Zeus", "Mars") > 0);
36                         Assert(cic.Compare ("Earth", "Venus") < 0);
37                 }
38
39                 [Test]
40                 public void TestIntsNEq()
41                 {
42                         int a =1;
43                         int b =2;                                   
44                         AssertEquals("#01",Comparer.Default.Compare(a,b),CaseInsensitiveComparer.Default.Compare(a,b));
45                 }
46                 
47                 [Test]
48                 public void TestIntsEq()
49                 {
50                         int a =1;
51                         int b =1;                                                                                
52                 
53                         AssertEquals("#02",Comparer.Default.Compare(a,b),CaseInsensitiveComparer.Default.Compare(a,b));
54                 }
55
56                 [Test]
57                 [ExpectedException (typeof (ArgumentNullException))]
58                 public void CtorNull()
59                 {
60                     new CaseInsensitiveComparer(null);
61                 }
62
63                 [Test]
64                 [ExpectedException (typeof (ArgumentException))]
65                 public void TestObject()
66                 {
67                     object a = new object();
68                     object b = new object();
69                     CaseInsensitiveComparer.Default.Compare(a,b);
70                 }
71
72                 [Test]
73                 [ExpectedException (typeof (ArgumentException))]
74                 public void TestDiffArgs()
75                 {
76                     int a = 5;
77                     string b = "hola";
78                     CaseInsensitiveComparer.Default.Compare(a,b);
79                 }
80
81                 [Test]
82                 public void TestNull1()
83                 {
84                         string a = null;
85                         string b = "5";
86
87                         AssertEquals("#04 Failed",Comparer.Default.Compare(a,b),CaseInsensitiveComparer.Default.Compare(a,b));
88                 }
89
90                 [Test]
91                 public void TestNull2()
92                 {
93                         string a = null;
94                         string b = null;
95
96                         AssertEquals("#05 Failed",Comparer.Default.Compare(a,b),CaseInsensitiveComparer.Default.Compare(a,b));
97                 }
98                 
99                 [Test]
100                 public void TestStringsCaps()
101                 {
102                         string a = "AA";
103                         string b = "aa";
104
105                         AssertEquals("#06 Failed",CaseInsensitiveComparer.Default.Compare(a,b),0);
106                 }
107       
108         }
109
110 }