New tests.
[mono.git] / mcs / class / System.Xaml / Test / System.Xaml / AttachableMemberIdentifierTest.cs
1 //
2 // Copyright (C) 2010 Novell Inc. http://novell.com
3 //
4 // Permission is hereby granted, free of charge, to any person obtaining
5 // a copy of this software and associated documentation files (the
6 // "Software"), to deal in the Software without restriction, including
7 // without limitation the rights to use, copy, modify, merge, publish,
8 // distribute, sublicense, and/or sell copies of the Software, and to
9 // permit persons to whom the Software is furnished to do so, subject to
10 // the following conditions:
11 // 
12 // The above copyright notice and this permission notice shall be
13 // included in all copies or substantial portions of the Software.
14 // 
15 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 //
23 using System;
24 using System.Collections;
25 using System.Collections.Generic;
26 using System.Xaml;
27 using NUnit.Framework;
28
29 namespace MonoTests.System.Xaml
30 {
31         [TestFixture]
32         public class AttachableMemberIdentifierTest
33         {
34                 [Test]
35                 public void NullTypeName ()
36                 {
37                         // It is not rejected. No dot.
38                         Assert.AreEqual ("Foo", new AttachableMemberIdentifier (null, "Foo").ToString (), "#1");
39                 }
40                 
41                 [Test]
42                 public void EmptyMemberName ()
43                 {
44                         // It is not rejected. Trailing dot.
45                         Assert.AreEqual ("System.String.", new AttachableMemberIdentifier (typeof (string), "").ToString (), "#1");
46                 }
47
48                 [Test]
49                 public void ToStringTest ()
50                 {
51                         Assert.AreEqual ("System.String.Foo", new AttachableMemberIdentifier (typeof (string), "Foo").ToString (), "#1");
52                         Assert.AreEqual ("System.Int32.Foo", new AttachableMemberIdentifier (typeof (int), "Foo").ToString (), "#2");
53                 }
54
55                 [Test]
56                 public void Equivalence ()
57                 {
58                         var a1 = new AttachableMemberIdentifier (typeof (string), "Foo");
59                         var a2 = new AttachableMemberIdentifier (typeof (string), "Foo");
60                         var a3 = new AttachableMemberIdentifier (null, "Foo");
61                         var a4 = new AttachableMemberIdentifier (null, "Foo");
62                         var a5 = new AttachableMemberIdentifier (typeof (string), null);
63                         var a6 = new AttachableMemberIdentifier (typeof (string), null);
64                         Assert.IsTrue (a1 == a2, "#1");
65                         Assert.IsFalse (a1 == a3, "#2");
66                         Assert.IsFalse (a1 == a5, "#3");
67                         Assert.IsTrue (a3 == a4, "#4");
68                         Assert.IsFalse (a3 == a1, "#5");
69                         Assert.IsFalse (a3 == a5, "#6");
70                         Assert.IsTrue (a5 == a6, "#7");
71                         Assert.IsFalse (a5 == a1, "#8");
72                         Assert.IsFalse (a5 == a3, "#9");
73                         Assert.IsTrue (a1.Equals (a2),"#11");
74                         Assert.IsFalse (a1.Equals (a3),"#12");
75                         Assert.IsFalse (a1.Equals (a5),"#13");
76                         Assert.IsTrue (a3.Equals (a4),"#14");
77                         Assert.IsFalse (a3.Equals (a1),"#15");
78                         Assert.IsFalse (a3.Equals (a5),"#16");
79                         Assert.IsTrue (a5.Equals (a6),"#17");
80                         Assert.IsFalse (a5.Equals (a1),"#18");
81                         Assert.IsFalse (a5.Equals (a3),"#19");
82                 }
83         }
84 }