Merge pull request #1936 from esdrubal/DotNetRelativeOrAbsolute
[mono.git] / mcs / class / corlib / Test / System / GuidTest.cs
1 //
2 // GuidTest.cs - NUnit Test Cases for the System.Guid struct
3 //
4 // Authors:
5 //      Duco Fijma (duco@lorentz.xs4all.nl)
6 //      Sebastien Pouliot  <sebastien@ximian.com>
7 //
8 // (C) 2002 Duco Fijma
9 // Copyright (C) 2005 Novell, Inc (http://www.novell.com)
10 //
11
12 using NUnit.Framework;
13 using System;
14
15 namespace MonoTests.System {
16
17         [TestFixture]
18         public class GuidTest {
19
20                 [Test]
21                 [ExpectedException (typeof (ArgumentNullException))]
22                 public void Constructor_ByteArray_Null ()
23                 {
24                         new Guid ((byte[]) null);
25                 }
26
27                 [Test]
28                 [ExpectedException (typeof (ArgumentException))]
29                 public void Constructor_ByteArray_InvalidLength ()
30                 {
31                         new Guid (new byte[] {0x00, 0x01, 0x02});
32                 }
33
34                 [Test]
35                 public void Constructor_ByteArray ()
36                 {
37                         Guid g =  new Guid (new byte[] {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f});
38                         Assert.AreEqual ("03020100-0504-0706-0809-0a0b0c0d0e0f", g.ToString ());
39                 }
40
41                 [Test]
42                 [ExpectedException (typeof (ArgumentNullException))]
43                 public void Constructor_String_Null ()
44                 {
45                         new Guid ((string) null);
46                 }
47
48                 [Test]
49                 public void Constructor_String ()
50                 {
51                         Guid g0 = new Guid ("000102030405060708090a0b0c0d0e0f"); 
52                         Guid g1 = new Guid ("00010203-0405-0607-0809-0a0b0c0d0e0f"); 
53                         Guid g2 = new Guid ("{00010203-0405-0607-0809-0A0B0C0D0E0F}"); 
54                         Guid g3 = new Guid ("{0x00010203,0x0405,0x0607,{0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f}}");
55                         Guid g4 = new Guid ("(00010203-0405-0607-0809-0A0B0C0D0E0F)");
56                         Guid g5 = new Guid ("\n  \r  \n 00010203-0405-0607-0809-0a0b0c0d0e0f \r\n");
57                         Guid g6 = new Guid ("\t {\t 0x00000001 , 0x0002 , \t 0x0003 \t , { 0x04 , 0x05 , \t 0x06\t,\t0x07 , 0x08 , 0x09 , 0x0a , 0x0b } \t }\t ");
58                         string expected = "00010203-0405-0607-0809-0a0b0c0d0e0f";
59                         Assert.AreEqual (expected, g0.ToString (), "A0");
60                         Assert.AreEqual (expected, g1.ToString (), "A1");
61                         Assert.AreEqual (expected, g2.ToString (), "A2");
62                         Assert.AreEqual (expected, g3.ToString (), "A3");
63                         Assert.AreEqual (expected, g4.ToString (), "A4");
64                         Assert.AreEqual (expected, g5.ToString (), "A5");
65                         Assert.AreEqual ("00000001-0002-0003-0405-060708090a0b", g6.ToString (), "A6");
66                 }
67
68                 [Test]
69                 [ExpectedException (typeof (FormatException))]
70                 public void Constructor_String_Invalid ()
71                 {
72                         new Guid ("invalid");
73                 }
74
75                 [Test]
76                 [ExpectedException (typeof (FormatException))]
77                 public void Constructor_String_MissingAllSeparators ()
78                 {
79                         new Guid ("{000102030405060708090A0B0C0D0E0F}");        // missing all -
80                 }
81
82                 [Test]
83                 [ExpectedException (typeof (FormatException))]
84                 public void Constructor_String_MissingSeparator ()
85                 {
86                         new Guid ("000102030405-0607-0809-0a0b0c0d0e0f");       // missing first -
87                 }
88
89                 [Test]
90                 [ExpectedException (typeof (FormatException))]
91                 public void Constructor_String_Mismatch ()
92                 {
93                         new Guid ("(000102030405-0607-0809-0a0b0c0d0e0f}");     // open (, close }
94                 }
95
96                 [Test]
97                 public void Constructor_Int32_2xInt16_8xByte ()
98                 {
99                         Guid g1 = new Guid (0x00010203, (short) 0x0405, (short) 0x0607, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f);
100                         Guid g2 = new Guid (unchecked ((int) 0xffffffff), unchecked ((short) 0xffff), unchecked((short) 0xffff), 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff);
101                         Guid g3 = new Guid (0x00010203u, (ushort) 0x0405u, (ushort) 0x0607u, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f);
102                         Guid g4 = new Guid (0xffffffffu, (ushort) 0xffffu, (ushort) 0xffffu, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff);
103                 
104                         Assert.AreEqual ("00010203-0405-0607-0809-0a0b0c0d0e0f", g1.ToString (), "A1");
105                         Assert.AreEqual ("ffffffff-ffff-ffff-ffff-ffffffffffff", g2.ToString (), "A2");
106                         Assert.AreEqual ("00010203-0405-0607-0809-0a0b0c0d0e0f", g1.ToString (), "A3");
107                         Assert.AreEqual ("ffffffff-ffff-ffff-ffff-ffffffffffff", g2.ToString (), "A4");
108                 }
109
110                 [Test]
111                 public void Constructor_UInt32_2xUInt16_8xByte ()
112                 {
113                         Guid g1 = new Guid (0x00010203u, (ushort) 0x0405u, (ushort) 0x0607u, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f);
114                         Guid g2 = new Guid (0xffffffffu, (ushort) 0xffffu, (ushort) 0xffffu, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff);
115                 
116                         Assert.AreEqual ("00010203-0405-0607-0809-0a0b0c0d0e0f", g1.ToString (), "A1");
117                         Assert.AreEqual ("ffffffff-ffff-ffff-ffff-ffffffffffff", g2.ToString (), "A2");
118                 }
119
120                 [Test]
121                 public void Constructor_Int32_2xInt16_ByteArray ()
122                 {
123                         Guid g1 = new Guid (0x00010203, (short) 0x0405, (short) 0x0607, new byte[] { 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f });
124                         Guid g2 = new Guid (unchecked ((int) 0xffffffff), unchecked ((short) 0xffff), unchecked((short) 0xffff), new byte[] { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff });
125                 
126                         Assert.AreEqual ("00010203-0405-0607-0809-0a0b0c0d0e0f", g1.ToString (), "A1");
127                         Assert.AreEqual ("ffffffff-ffff-ffff-ffff-ffffffffffff", g2.ToString (), "A2");
128                 }
129
130                 [Test]
131                 public void Empty ()
132                 {
133                         Assert.AreEqual ("00000000-0000-0000-0000-000000000000", Guid.Empty.ToString (), "ToString");
134                         Assert.AreEqual (new byte [16], Guid.Empty.ToByteArray (), "ToByteArray");
135                 }
136
137                 [Test]
138                 public void NewGuid ()
139                 {
140                         Guid g1 = Guid.NewGuid ();
141                         Guid g2 = Guid.NewGuid ();
142                         Assert.IsFalse (g1 == g2);
143                 }
144
145                 [Test]
146                 public void NewGuid_Stressed ()
147                 {
148                         for (int i = 0; i < 256; i++) {
149                                 Guid g = Guid.NewGuid ();
150                                 Assert.AreNotEqual (0, g.CompareTo (Guid.Empty), i.ToString ());
151                         }
152                 }
153
154 #pragma warning disable 1718
155                 [Test]
156                 public void EqualityOp ()
157                 {
158                         Guid g1 = new Guid (0x00010203, 0x0405, 0x0607, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f);
159                         Guid g2 = new Guid (0x00010203, 0x0405, 0x0607, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f);
160                         Guid g3 = new Guid (0x11223344, 0x5566, 0x6677, 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff);
161
162                         Assert.IsTrue (g1 == g1, "A1");
163                         Assert.IsTrue (g1 == g2, "A2");
164                         Assert.IsFalse (g1 == g3, "A3");
165                 }
166
167                 [Test]
168                 public void InequalityOp ()
169                 {
170                         Guid g1 = new Guid (0x00010203, 0x0405, 0x0607, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f);
171                         Guid g2 = new Guid (0x00010203, 0x0405, 0x0607, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f);
172                         Guid g3 = new Guid (0x11223344, 0x5566, 0x6677, 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff);
173
174                         Assert.IsFalse (g1 != g1, "A1");
175                         Assert.IsFalse (g1 != g2, "A2");
176                         Assert.IsTrue (g1 != g3, "A3");
177                 }
178 #pragma warning restore 1718
179
180                 [Test]
181                 public void EqualsObject ()
182                 {
183                         Guid g1 = new Guid (0x00010203, 0x0405, 0x0607, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f);
184                         Guid g2 = new Guid (0x00010203, 0x0405, 0x0607, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f);
185                         Guid g3 = new Guid (0x11223344, 0x5566, 0x6677, 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff);
186                         // cast everything to object so the test still works under 2.0
187                         Assert.IsTrue (g1.Equals ((object)g1), "A1");
188                         Assert.IsTrue (g1.Equals ((object)g2), "A2");
189                         Assert.IsFalse (g1.Equals ((object)g3), "A3");
190                         Assert.IsFalse (g1.Equals ((object)null), "A4");
191                         Assert.IsFalse (g1.Equals ((object)"This is not a Guid!"), "A5");
192                 }
193
194
195                 [Test]
196                 public void EqualsGuid ()
197                 {
198                         Guid g1 = new Guid (0x00010203, 0x0405, 0x0607, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f);
199                         Guid g2 = new Guid (0x00010203, 0x0405, 0x0607, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f);
200                         Guid g3 = new Guid (0x11223344, 0x5566, 0x6677, 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff);
201
202                         Assert.IsTrue (g1.Equals (g1), "A1");
203                         Assert.IsTrue (g1.Equals (g2), "A2");
204                         Assert.IsFalse (g1.Equals (g3), "A3");
205                         Assert.IsFalse (g1.Equals (null), "A4");
206                         Assert.IsFalse (g1.Equals ("This is not a Guid!"), "A5");
207                 }
208
209                 [Test]
210                 public void CompareToObject ()
211                 {
212                         Guid g1 = new Guid (0x00010203, 0x0405, 0x0607, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f);
213                         Guid g2 = new Guid (0x00010204, 0x0405, 0x0607, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f);
214                         Guid g3 = new Guid (0x00010203, 0x0405, 0x0607, 0x09, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f);
215                         Guid g4 = new Guid (0x00010203, 0x0405, 0x0607, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x1f);
216                         // cast everything to object so the test still works under 2.0
217                         Assert.IsTrue (g1.CompareTo ((object)g2) < 0, "A1");
218                         Assert.IsTrue (g1.CompareTo ((object)g3) < 0, "A2");
219                         Assert.IsTrue (g1.CompareTo ((object)g4) < 0, "A3");
220                         Assert.IsTrue (g2.CompareTo ((object)g1) > 0, "A4");
221                         Assert.IsTrue (g3.CompareTo ((object)g1) > 0, "A5");
222                         Assert.IsTrue (g4.CompareTo ((object)g1) > 0, "A6");
223                         Assert.IsTrue (g1.CompareTo ((object)g1) == 0, "A7");
224                         Assert.IsTrue (g1.CompareTo ((object)null) > 0, "A8");
225                 }
226
227                 [Test]
228                 [ExpectedException (typeof (ArgumentException))]
229                 public void CompareToObject_Invalid ()
230                 {
231                         Guid.Empty.CompareTo ("Say what?");
232                 }
233
234                 [Test]
235                 public void CompareToGuid ()
236                 {
237                         Guid g1 = new Guid (0x00010203, 0x0405, 0x0607, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f);
238                         Guid g2 = new Guid (0x00010204, 0x0405, 0x0607, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f);
239                         Guid g3 = new Guid (0x00010203, 0x0405, 0x0607, 0x09, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f);
240                         Guid g4 = new Guid (0x00010203, 0x0405, 0x0607, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x1f);
241
242                         Assert.IsTrue (g1.CompareTo (g2) < 0, "A1");
243                         Assert.IsTrue (g1.CompareTo (g3) < 0, "A2");
244                         Assert.IsTrue (g1.CompareTo (g4) < 0, "A3");
245                         Assert.IsTrue (g2.CompareTo (g1) > 0, "A4");
246                         Assert.IsTrue (g3.CompareTo (g1) > 0, "A5");
247                         Assert.IsTrue (g4.CompareTo (g1) > 0, "A6");
248                         Assert.IsTrue (g1.CompareTo (g1) == 0, "A7");
249                 }
250
251                 [Test]
252                 public void CompareToGuid_2 ()
253                 {
254                         var g1 = new Guid ("d1c5088bc188464fb77b0fd2be2d005e");
255                         var g2 = new Guid ("d2c5088bc188464fb77b0fd2be2d005e");
256                         var g3 = new Guid ("00c5088bc188464fb77b0fd2be2d005e");
257
258                         Assert.AreEqual (-1, g1.CompareTo (g2), "#1");
259                         Assert.AreEqual (1, g1.CompareTo (g3), "#2");
260                         Assert.AreEqual (1, g1.CompareTo (Guid.Empty), "#3");
261                 }
262
263                 [Test]
264                 public void GetHashCode_Same ()
265                 {
266                         Guid copy = new Guid (Guid.Empty.ToString ());
267                         Assert.AreEqual (Guid.Empty.GetHashCode (), copy.GetHashCode (), "GetHashCode");
268                 }
269
270                 [Test]
271                 public void GetHashCode_Different ()
272                 {
273                         Guid g = Guid.NewGuid ();
274                         Assert.IsFalse (Guid.Empty.GetHashCode () == g.GetHashCode (), "GetHashCode");
275                 }
276
277                 [Test]
278                 public void ToByteArray ()
279                 {
280                         Guid g1 = new Guid (0x00010203, 0x0405, 0x0607, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f);
281                         byte[] expected = new byte[] { 0x03, 0x02, 0x01, 0x00, 0x05, 0x04, 0x07, 0x06, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F };
282                         Assert.AreEqual (expected, g1.ToByteArray (), "ToByteArray");
283                 }
284
285                 [Test]
286                 public void ToString_AllFormats ()
287                 {
288                         Guid g = new Guid (0x00010203, 0x0405, 0x0607, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f);
289                         Assert.AreEqual ("00010203-0405-0607-0809-0a0b0c0d0e0f", g.ToString (), "A1");
290                         Assert.AreEqual ("000102030405060708090a0b0c0d0e0f", g.ToString ("N"), "A2");
291                         Assert.AreEqual ("00010203-0405-0607-0809-0a0b0c0d0e0f", g.ToString ("D"), "A3");
292                         Assert.AreEqual ("{00010203-0405-0607-0809-0a0b0c0d0e0f}", g.ToString ("B"), "A4");
293                         Assert.AreEqual ("(00010203-0405-0607-0809-0a0b0c0d0e0f)", g.ToString ("P"), "A5");
294                         Assert.AreEqual ("00010203-0405-0607-0809-0a0b0c0d0e0f", g.ToString (""), "A6");
295                         Assert.AreEqual ("00010203-0405-0607-0809-0a0b0c0d0e0f", g.ToString ((string)null), "A7");
296                         Assert.AreEqual ("{00010203-0405-0607-0809-0a0b0c0d0e0f}", g.ToString ("B", null), "A10");
297                         Assert.AreEqual ("{0x00010203,0x0405,0x0607,{0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f}}", g.ToString ("x"), "A11");
298                         Assert.AreEqual ("{0x00010203,0x0405,0x0607,{0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f}}", g.ToString ("X"), "A11");
299                 }
300
301
302                 [Test]
303                 [ExpectedException (typeof (FormatException))]
304                 public void ToString_InvalidFormat ()
305                 {
306                         new Guid (0x00010203, 0x0405, 0x0607, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f).ToString ("This is invalid");
307                 }
308
309                 [Test]
310                 [ExpectedException (typeof (FormatException))]
311                 public void ParseExtraJunkN ()
312                 {
313                         new Guid ("000102030405060708090a0b0c0d0e0faaaaaa");
314                 }
315
316                 [Test]
317                 [ExpectedException (typeof (FormatException))]
318                 public void ParseExtraJunkD ()
319                 {
320                         new Guid ("00010203-0405-0607-0809-0a0b0c0d0e0faaaaaa");
321                 }
322
323                 [Test]
324                 [ExpectedException (typeof (FormatException))]
325                 public void ParseExtraJunkB ()
326                 {
327                         new Guid ("{00010203-0405-0607-0809-0A0B0C0D0E0F}aaaa");
328                 }
329
330                 [Test]
331                 [ExpectedException (typeof (FormatException))]
332                 public void ParseExtraJunkP ()
333                 {
334                         new Guid ("(00010203-0405-0607-0809-0A0B0C0D0E0F)aaaa");
335                 }
336
337                 [Test]
338                 [ExpectedException (typeof (FormatException))]
339                 public void ParseExtraJunkX ()
340                 {
341                         new Guid ("{0x00010203,0x0405,0x0607,{0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f}}aaaa");
342                 }
343
344
345                 /*
346                         N = new Guid ("000102030405060708090a0b0c0d0e0f"); 
347                         D = new Guid ("00010203-0405-0607-0809-0a0b0c0d0e0f"); 
348                         B = new Guid ("{00010203-0405-0607-0809-0A0B0C0D0E0F}"); 
349                         P = new Guid ("(00010203-0405-0607-0809-0A0B0C0D0E0F)");
350                         X = new Guid ("{0x00010203,0x0405,0x0607,{0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f}}");
351
352                         string expected = "00010203-0405-0607-0809-0a0b0c0d0e0f";
353                 */
354
355                 [Test]
356                 public void ParseExact ()
357                 {
358                         const string expected = "00010203-0405-0607-0809-0a0b0c0d0e0f";
359
360                         var guid = Guid.ParseExact ("000102030405060708090a0b0c0d0e0f", "N");
361                         Assert.AreEqual (expected, guid.ToString ());
362
363                         guid = Guid.ParseExact ("00010203-0405-0607-0809-0a0b0c0d0e0f", "D");
364                         Assert.AreEqual (expected, guid.ToString ());
365
366                         guid = Guid.ParseExact ("00010203-0405-0607-0809-0a0b0c0d0e0f", "d");
367                         Assert.AreEqual (expected, guid.ToString ());
368
369                         guid = Guid.ParseExact ("{00010203-0405-0607-0809-0A0B0C0D0E0F}", "B");
370                         Assert.AreEqual (expected, guid.ToString ());
371
372                         guid = Guid.ParseExact ("{00010203-0405-0607-0809-0A0B0C0D0E0F}", "b");
373                         Assert.AreEqual (expected, guid.ToString ());
374
375                         guid = Guid.ParseExact ("(00010203-0405-0607-0809-0A0B0C0D0E0F)", "P");
376                         Assert.AreEqual (expected, guid.ToString ());
377
378                         guid = Guid.ParseExact ("{0x00010203,0x0405,0x0607,{0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f}}", "X");
379                         Assert.AreEqual (expected, guid.ToString ());
380
381                         guid = Guid.ParseExact ("\t {\t 0x00000001 , 0x0002 , \t 0x0003 \t , { 0x04 , 0x05 , \t 0x06\t,\t0x07 , 0x08 , 0x09 , 0x0a , 0x0b } \t }\t ", "X");
382                         Assert.AreEqual ("00000001-0002-0003-0405-060708090a0b", guid.ToString (), "#8");
383                 }
384
385                 [Test]
386                 public void Parse ()
387                 {
388                         var guid = Guid.Parse ("\t {\t 0x00000001 , 0x0002 , \t 0x0003 \t , { 0x04 , 0x05 , \t 0x06\t,\t0x07 , 0x08 , 0x09 , 0x0a , 0x0b } \t }\t ");
389                         Assert.AreEqual ("00000001-0002-0003-0405-060708090a0b", guid.ToString (), "#1");
390                 }
391
392                 [Test]
393                 [ExpectedException (typeof (FormatException))]
394                 public void ParseError_1 ()
395                 {
396                         Guid.Parse("08888888-0444-444-0444-012121212121");
397                 }
398
399                 [Test]
400                 [ExpectedException (typeof (FormatException))]
401                 public void ParseExactN ()
402                 {
403                         Guid.ParseExact ("00010203-0405-0607-0809-0a0b0c0d0e0f", "N");
404                 }
405
406                 [Test]
407                 [ExpectedException (typeof (FormatException))]
408                 public void ParseExactD ()
409                 {
410                         Guid.ParseExact ("{0x00010203,0x0405,0x0607,{0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f}}", "D");
411                 }
412
413                 [Test]
414                 public void TryParse()
415                 {
416                         Guid guid;
417                         Assert.IsFalse (Guid.TryParse(null, out guid), "A1");
418                         Assert.AreEqual (Guid.Empty, guid, "A2");
419                         Assert.IsFalse (Guid.TryParse("", out guid), "A3");
420                         Assert.AreEqual (Guid.Empty, guid, "A4");
421                         Assert.IsFalse (Guid.TryParse("foobar", out guid), "A5");
422                         Assert.AreEqual (Guid.Empty, guid, "A6");
423                         Assert.IsFalse (Guid.TryParse ("08888888-0444-444-0444-012121212121", out guid), "A7");
424                 }
425
426                 [Test]
427                 public void TryParseExact()
428                 {
429                         Guid guid;
430                         Assert.IsFalse (Guid.TryParseExact(null, null, out guid), "A1");
431                         Assert.AreEqual (Guid.Empty, guid, "A2");
432                         Assert.IsFalse (Guid.TryParseExact("", null, out guid), "A3");
433                         Assert.AreEqual (Guid.Empty, guid, "A4");
434                         Assert.IsFalse (Guid.TryParseExact("foobar", null, out guid), "A5");
435                         Assert.AreEqual (Guid.Empty, guid, "A6");
436                 }
437         }
438 }