[eglib] Prefer <langinfo.h> to <localcharset.h>
[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 #if NET_4_0
298                         Assert.AreEqual ("{0x00010203,0x0405,0x0607,{0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f}}", g.ToString ("x"), "A11");
299                         Assert.AreEqual ("{0x00010203,0x0405,0x0607,{0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f}}", g.ToString ("X"), "A11");
300 #endif
301                 }
302
303 #if !NET_4_0
304                 [Test]
305                 [ExpectedException (typeof (FormatException))]
306                 public void ToString_UnsupportedFormat ()
307                 {
308                         new Guid (0x00010203, 0x0405, 0x0607, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f).ToString ("X");
309                 }
310 #endif
311
312                 [Test]
313                 [ExpectedException (typeof (FormatException))]
314                 public void ToString_InvalidFormat ()
315                 {
316                         new Guid (0x00010203, 0x0405, 0x0607, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f).ToString ("This is invalid");
317                 }
318
319                 [Test]
320                 [ExpectedException (typeof (FormatException))]
321                 public void ParseExtraJunkN ()
322                 {
323                         new Guid ("000102030405060708090a0b0c0d0e0faaaaaa");
324                 }
325
326                 [Test]
327                 [ExpectedException (typeof (FormatException))]
328                 public void ParseExtraJunkD ()
329                 {
330                         new Guid ("00010203-0405-0607-0809-0a0b0c0d0e0faaaaaa");
331                 }
332
333                 [Test]
334                 [ExpectedException (typeof (FormatException))]
335                 public void ParseExtraJunkB ()
336                 {
337                         new Guid ("{00010203-0405-0607-0809-0A0B0C0D0E0F}aaaa");
338                 }
339
340                 [Test]
341                 [ExpectedException (typeof (FormatException))]
342                 public void ParseExtraJunkP ()
343                 {
344                         new Guid ("(00010203-0405-0607-0809-0A0B0C0D0E0F)aaaa");
345                 }
346
347                 [Test]
348                 [ExpectedException (typeof (FormatException))]
349                 public void ParseExtraJunkX ()
350                 {
351                         new Guid ("{0x00010203,0x0405,0x0607,{0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f}}aaaa");
352                 }
353
354 #if NET_4_0
355
356                 /*
357                         N = new Guid ("000102030405060708090a0b0c0d0e0f"); 
358                         D = new Guid ("00010203-0405-0607-0809-0a0b0c0d0e0f"); 
359                         B = new Guid ("{00010203-0405-0607-0809-0A0B0C0D0E0F}"); 
360                         P = new Guid ("(00010203-0405-0607-0809-0A0B0C0D0E0F)");
361                         X = new Guid ("{0x00010203,0x0405,0x0607,{0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f}}");
362
363                         string expected = "00010203-0405-0607-0809-0a0b0c0d0e0f";
364                 */
365
366                 [Test]
367                 public void ParseExact ()
368                 {
369                         const string expected = "00010203-0405-0607-0809-0a0b0c0d0e0f";
370
371                         var guid = Guid.ParseExact ("000102030405060708090a0b0c0d0e0f", "N");
372                         Assert.AreEqual (expected, guid.ToString ());
373
374                         guid = Guid.ParseExact ("00010203-0405-0607-0809-0a0b0c0d0e0f", "D");
375                         Assert.AreEqual (expected, guid.ToString ());
376
377                         guid = Guid.ParseExact ("00010203-0405-0607-0809-0a0b0c0d0e0f", "d");
378                         Assert.AreEqual (expected, guid.ToString ());
379
380                         guid = Guid.ParseExact ("{00010203-0405-0607-0809-0A0B0C0D0E0F}", "B");
381                         Assert.AreEqual (expected, guid.ToString ());
382
383                         guid = Guid.ParseExact ("{00010203-0405-0607-0809-0A0B0C0D0E0F}", "b");
384                         Assert.AreEqual (expected, guid.ToString ());
385
386                         guid = Guid.ParseExact ("(00010203-0405-0607-0809-0A0B0C0D0E0F)", "P");
387                         Assert.AreEqual (expected, guid.ToString ());
388
389                         guid = Guid.ParseExact ("{0x00010203,0x0405,0x0607,{0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f}}", "X");
390                         Assert.AreEqual (expected, guid.ToString ());
391
392                         guid = Guid.ParseExact ("\t {\t 0x00000001 , 0x0002 , \t 0x0003 \t , { 0x04 , 0x05 , \t 0x06\t,\t0x07 , 0x08 , 0x09 , 0x0a , 0x0b } \t }\t ", "X");
393                         Assert.AreEqual ("00000001-0002-0003-0405-060708090a0b", guid.ToString (), "#8");
394                 }
395
396                 [Test]
397                 public void Parse ()
398                 {
399                         var guid = Guid.Parse ("\t {\t 0x00000001 , 0x0002 , \t 0x0003 \t , { 0x04 , 0x05 , \t 0x06\t,\t0x07 , 0x08 , 0x09 , 0x0a , 0x0b } \t }\t ");
400                         Assert.AreEqual ("00000001-0002-0003-0405-060708090a0b", guid.ToString (), "#1");
401                 }
402
403                 [Test]
404                 [ExpectedException (typeof (FormatException))]
405                 public void ParseError_1 ()
406                 {
407                         Guid.Parse("08888888-0444-444-0444-012121212121");
408                 }
409
410                 [Test]
411                 [ExpectedException (typeof (FormatException))]
412                 public void ParseExactN ()
413                 {
414                         Guid.ParseExact ("00010203-0405-0607-0809-0a0b0c0d0e0f", "N");
415                 }
416
417                 [Test]
418                 [ExpectedException (typeof (FormatException))]
419                 public void ParseExactD ()
420                 {
421                         Guid.ParseExact ("{0x00010203,0x0405,0x0607,{0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f}}", "D");
422                 }
423
424                 [Test]
425                 public void TryParse()
426                 {
427                         Guid guid;
428                         Assert.IsFalse (Guid.TryParse(null, out guid), "A1");
429                         Assert.AreEqual (Guid.Empty, guid, "A2");
430                         Assert.IsFalse (Guid.TryParse("", out guid), "A3");
431                         Assert.AreEqual (Guid.Empty, guid, "A4");
432                         Assert.IsFalse (Guid.TryParse("foobar", out guid), "A5");
433                         Assert.AreEqual (Guid.Empty, guid, "A6");
434                         Assert.IsFalse (Guid.TryParse ("08888888-0444-444-0444-012121212121", out guid), "A7");
435                 }
436
437                 [Test]
438                 public void TryParseExact()
439                 {
440                         Guid guid;
441                         Assert.IsFalse (Guid.TryParseExact(null, null, out guid), "A1");
442                         Assert.AreEqual (Guid.Empty, guid, "A2");
443                         Assert.IsFalse (Guid.TryParseExact("", null, out guid), "A3");
444                         Assert.AreEqual (Guid.Empty, guid, "A4");
445                         Assert.IsFalse (Guid.TryParseExact("foobar", null, out guid), "A5");
446                         Assert.AreEqual (Guid.Empty, guid, "A6");
447                 }
448 #endif
449         }
450 }