New tests, update
[mono.git] / mcs / class / corlib / Test / System.IO / MemoryStreamTest.cs
1 //
2 // System.IO.MemoryStreamTest
3 //
4 // Authors:
5 //      Marcin Szczepanski (marcins@zipworld.com.au)
6 //      Gonzalo Paniagua Javier (gonzalo@ximian.com)
7 //      Sebastien Pouliot  <sebastien@ximian.com>
8 //
9 // (c) 2003 Ximian, Inc. (http://www.ximian.com)
10 // Copyright (C) 2004 Novell (http://www.novell.com)
11 //
12
13 using System;
14 using System.IO;
15 using System.Runtime.Serialization.Formatters.Binary;
16 using System.Text;
17
18 using NUnit.Framework;
19
20 namespace MonoTests.System.IO
21 {
22         [TestFixture]
23         public class MemoryStreamTest
24         {
25                 MemoryStream testStream;
26                 byte [] testStreamData;
27
28                 [SetUp]
29                 public void SetUp ()
30                 {
31                         testStreamData = new byte [100];
32
33                         for (int i = 0; i < 100; i++)
34                                 testStreamData[i] = (byte) (100 - i);
35
36                         testStream = new MemoryStream (testStreamData);
37                 }
38
39                 // 
40                 // Verify that the first count bytes in testBytes are the same as
41                 // the count bytes from index start in testStreamData
42                 //
43                 void VerifyTestData (string id, byte [] testBytes, int start, int count)
44                 {
45                         if (testBytes == null)
46                                 Assert.Fail (id + "+1 testBytes is null");
47
48                         if (start < 0 ||
49                             count < 0  ||
50                             start + count > testStreamData.Length ||
51                             start > testStreamData.Length)
52                                 throw new ArgumentOutOfRangeException (id + "+2");
53
54                         for (int test = 0; test < count; test++) {
55                                 if (testBytes [test] == testStreamData [start + test])
56                                         continue;
57
58                                 string failStr = "testByte {0} (testStream {1}) was <{2}>, expecting <{3}>";
59                                 failStr = String.Format (failStr,
60                                                         test,
61                                                         start + test,
62                                                         testBytes [test],
63                                                         testStreamData [start + test]);
64                                 Assert.Fail (id + "-3" + failStr);
65                         }
66                 }
67
68                 public void AssertEquals (string message, int expected, int actual)
69                 {
70                         Assert.AreEqual (expected, actual, message);
71                 }
72
73                 public void AssertEquals (string message, long expected, long actual)
74                 {
75                         Assert.AreEqual (expected, actual, message);
76                 }
77
78                 public void AssertEquals (string message, bool expected, bool actual)
79                 {
80                         Assert.AreEqual (expected, actual, message);
81                 }
82
83                 [Test]
84                 public void ConstructorsOne ()
85                 {
86                         MemoryStream ms = new MemoryStream();
87
88                         AssertEquals ("#01", 0L, ms.Length);
89                         AssertEquals ("#02", 0, ms.Capacity);
90                         AssertEquals ("#03", true, ms.CanWrite);
91                 }
92
93                 [Test]
94                 public void ConstructorsTwo ()
95                 {
96                         MemoryStream ms = new MemoryStream (10);
97
98                         AssertEquals ("#01", 0L, ms.Length);
99                         AssertEquals ("#02", 10, ms.Capacity);
100                         ms.Capacity = 0;
101                         byte [] buffer = ms.GetBuffer ();
102                         // Begin: wow!!!
103                         AssertEquals ("#03", -1, ms.ReadByte ());
104                         Assert.IsNull (buffer, "#04"); // <--
105                         ms.Read (new byte [5], 0, 5);
106                         AssertEquals ("#05", 0, ms.Position);
107                         AssertEquals ("#06", 0, ms.Length);
108                         // End
109                 }
110
111                 [Test]
112                 public void ConstructorsThree ()
113                 {
114                         MemoryStream ms = new MemoryStream (testStreamData);
115                         AssertEquals ("#01", 100, ms.Length);
116                         AssertEquals ("#02", 0, ms.Position);
117                 }
118
119                 [Test]
120                 public void ConstructorsFour ()
121                 {
122                         MemoryStream ms = new MemoryStream (testStreamData, true);
123                         AssertEquals ("#01", 100, ms.Length);
124                         AssertEquals ("#02", 0, ms.Position);
125                         ms.Position = 50;
126                         byte saved = testStreamData [50];
127                         try {
128                                 ms.WriteByte (23);
129                                 AssertEquals ("#03", testStreamData [50], 23);
130                         } finally {
131                                 testStreamData [50] = saved;
132                         }
133                         ms.Position = 100;
134                         try {
135                                 ms.WriteByte (23);
136                         } catch (Exception) {
137                                 return;
138                         }
139                         Assert.Fail ("#04");
140                 }
141
142                 [Test]
143                 public void ConstructorsFive ()
144                 {
145                         MemoryStream ms = new MemoryStream (testStreamData, 50, 50);
146                         AssertEquals ("#01", 50, ms.Length);
147                         AssertEquals ("#02", 0, ms.Position);
148                         AssertEquals ("#03", 50, ms.Capacity);
149                         ms.Position = 1;
150                         byte saved = testStreamData [51];
151                         try {
152                                 ms.WriteByte (23);
153                                 AssertEquals ("#04", testStreamData [51], 23);
154                         } finally {
155                                 testStreamData [51] = saved;
156                         }
157                         ms.Position = 100;
158                         bool gotException = false;
159                         try {
160                                 ms.WriteByte (23);
161                         } catch (NotSupportedException) {
162                                 gotException = true;
163                         }
164
165                         if (!gotException)
166                                 Assert.Fail ("#05");
167
168                         ms.Capacity = 100; // Allowed. It's the same as the one in the ms.
169                                            // This is lame, as the length is 50!!!
170                                            
171                         gotException = false;
172                         try {
173                                 ms.Capacity = 51;
174                         } catch (NotSupportedException) {
175                                 gotException = true;
176                         }
177
178                         if (!gotException)
179                                 Assert.Fail ("#07");
180
181                         AssertEquals ("#08", 50, ms.ToArray ().Length);
182                 }
183
184                 [Test]
185                 [ExpectedException (typeof (ArgumentOutOfRangeException))]
186                 public void ConstructorsSix ()
187                 {
188                         MemoryStream ms = new MemoryStream (-2);
189                 }
190
191                 [Test]
192                 public void Read ()
193                 {
194                         byte [] readBytes = new byte [20];
195
196                         /* Test simple read */
197                         testStream.Read (readBytes, 0, 10);
198                         VerifyTestData ("R1", readBytes, 0, 10);
199
200                         /* Seek back to beginning */
201
202                         testStream.Seek (0, SeekOrigin.Begin);
203
204                         /* Read again, bit more this time */
205                         testStream.Read (readBytes, 0, 20);
206                         VerifyTestData ("R2", readBytes, 0, 20);
207
208                         /* Seek to 20 bytes from End */
209                         testStream.Seek (-20, SeekOrigin.End);
210                         testStream.Read (readBytes, 0, 20);
211                         VerifyTestData ("R3", readBytes, 80, 20);
212
213                         int readByte = testStream.ReadByte();
214                         Assert.AreEqual (-1, readByte, "R4");
215                 }
216
217                 [Test]
218                 public void WriteBytes ()
219                 {
220                         byte[] readBytes = new byte[100];
221
222                         MemoryStream ms = new MemoryStream (100);
223
224                         for (int i = 0; i < 100; i++)
225                                 ms.WriteByte (testStreamData [i]);
226
227                         ms.Seek (0, SeekOrigin.Begin); 
228                         testStream.Read (readBytes, 0, 100);
229                         VerifyTestData ("W1", readBytes, 0, 100);
230                 }
231
232                 [Test]
233                 public void WriteBlock ()
234                 {
235                         byte[] readBytes = new byte[100];
236
237                         MemoryStream ms = new MemoryStream (100);
238
239                         ms.Write (testStreamData, 0, 100);
240                         ms.Seek (0, SeekOrigin.Begin); 
241                         testStream.Read (readBytes, 0, 100);
242                         VerifyTestData ("WB1", readBytes, 0, 100);
243                         byte[] arrayBytes = testStream.ToArray();
244                         AssertEquals ("#01", 100, arrayBytes.Length);
245                         VerifyTestData ("WB2", arrayBytes, 0, 100);
246                 }
247
248                 [Test]
249                 public void PositionLength ()
250                 {
251                         MemoryStream ms = new MemoryStream ();
252                         ms.Position = 4;
253                         ms.WriteByte ((byte) 'M');
254                         ms.WriteByte ((byte) 'O');
255                         AssertEquals ("#01", 6, ms.Length);
256                         AssertEquals ("#02", 6, ms.Position);
257                         ms.Position = 0;
258                         AssertEquals ("#03", 0, ms.Position);
259                 }
260
261                 [Test]
262                 [ExpectedException (typeof (NotSupportedException))]
263                 public void MorePositionLength ()
264                 {
265                         MemoryStream ms = new MemoryStream (testStreamData);
266                         ms.Position = 101;
267                         AssertEquals ("#01", 101, ms.Position);
268                         AssertEquals ("#02", 100, ms.Length);
269                         ms.WriteByte (1); // This should throw the exception
270                 }
271
272                 [Test]
273                 public void GetBufferOne ()
274                 {
275                         MemoryStream ms = new MemoryStream ();
276                         byte [] buffer = ms.GetBuffer ();
277                         AssertEquals ("#01", 0, buffer.Length);
278                 }
279
280                 [Test]
281                 public void GetBufferTwo ()
282                 {
283                         MemoryStream ms = new MemoryStream (100);
284                         byte [] buffer = ms.GetBuffer ();
285                         AssertEquals ("#01", 100, buffer.Length);
286
287                         ms.Write (testStreamData, 0, 100);
288                         ms.Write (testStreamData, 0, 100);
289                         AssertEquals ("#02", 200, ms.Length);
290                         buffer = ms.GetBuffer ();
291                         AssertEquals ("#03", 256, buffer.Length); // Minimun size after writing
292                 }
293
294                 [Test]
295                 public void Closed ()
296                 {
297                         MemoryStream ms = new MemoryStream (100);
298                         ms.Close ();
299                         bool thrown = false;
300                         try {
301                                 int x = ms.Capacity;
302                         } catch (ObjectDisposedException) {
303                                 thrown = true;
304                         }
305
306                         if (!thrown)
307                                 Assert.Fail ("#01");
308
309                         thrown = false;
310                         try {
311                                 ms.Capacity = 1;
312                         } catch (ObjectDisposedException) {
313                                 thrown = true;
314                         }
315
316                         if (!thrown)
317                                 Assert.Fail ("#02");
318
319                         // The first exception thrown is ObjectDisposed, not ArgumentNull
320                         thrown = false;
321                         try {
322                                 ms.Read (null, 0, 1);
323                         } catch (ObjectDisposedException) {
324                                 thrown = true;
325                         }
326
327                         if (!thrown)
328                                 Assert.Fail ("#03");
329
330                         thrown = false;
331                         try {
332                                 ms.Write (null, 0, 1);
333                         } catch (ObjectDisposedException) {
334                                 thrown = true;
335                         }
336
337                         if (!thrown)
338                                 Assert.Fail ("#03");
339                 }
340
341                 [Test]
342                 [ExpectedException (typeof (ObjectDisposedException))]
343                 public void Close_get_Length () 
344                 {
345                         MemoryStream ms = new MemoryStream (100);
346                         ms.Close ();
347                         long x = ms.Length;
348                 }
349
350                 [Test]
351                 [ExpectedException (typeof (ObjectDisposedException))]
352                 public void Close_get_Position () 
353                 {
354                         MemoryStream ms = new MemoryStream (100);
355                         ms.Close ();
356                         long x = ms.Position;
357                 }
358
359                 [Test]
360                 [ExpectedException (typeof (ObjectDisposedException))]
361                 public void Close_set_Position () 
362                 {
363                         MemoryStream ms = new MemoryStream (100);
364                         ms.Close ();
365                         ms.Position = 0;
366                 }
367
368                 [Test]
369                 public void Seek ()
370                 {
371                         MemoryStream ms = new MemoryStream (100);
372                         ms.Write (testStreamData, 0, 100);
373                         ms.Seek (0, SeekOrigin.Begin);
374                         ms.Position = 50;
375                         ms.Seek (-50, SeekOrigin.Current);
376                         ms.Seek (-50, SeekOrigin.End);
377
378                         bool thrown = false;
379                         ms.Position = 49;
380                         try {
381                                 ms.Seek (-50, SeekOrigin.Current);
382                         } catch (IOException) {
383                                 thrown = true;
384                         }
385                         if (!thrown)
386                                 Assert.Fail ("#01");
387                         
388                         thrown = false;
389                         try {
390                                 ms.Seek (Int64.MaxValue, SeekOrigin.Begin);
391                         } catch (ArgumentOutOfRangeException) {
392                                 thrown = true;
393                         }
394
395                         if (!thrown)
396                                 Assert.Fail ("#02");
397
398                         thrown=false;
399                         try {
400                                 // Oh, yes. They throw IOException for this one, but ArgumentOutOfRange for the previous one
401                                 ms.Seek (Int64.MinValue, SeekOrigin.Begin);
402                         } catch (IOException) {
403                                 thrown = true;
404                         }
405
406                         if (!thrown)
407                                 Assert.Fail ("#03");
408
409                         ms=new MemoryStream (256);
410
411                         ms.Write (testStreamData, 0, 100);
412                         ms.Position=0;
413                         AssertEquals ("#01", 100, ms.Length);
414                         AssertEquals ("#02", 0, ms.Position);
415
416                         ms.Position=128;
417                         AssertEquals ("#03", 100, ms.Length);
418                         AssertEquals ("#04", 128, ms.Position);
419
420                         ms.Position=768;
421                         AssertEquals ("#05", 100, ms.Length);
422                         AssertEquals ("#06", 768, ms.Position);
423
424                         ms.WriteByte (0);
425                         AssertEquals ("#07", 769, ms.Length);
426                         AssertEquals ("#08", 769, ms.Position);
427                 }
428
429                 [Test]
430                 public void Seek_Disposed () 
431                 {
432                         MemoryStream ms = new MemoryStream ();
433                         ms.Close ();
434                         try {
435                                 ms.Seek (0, SeekOrigin.Begin);
436                                 Assert.Fail ();
437                         } catch (ObjectDisposedException) {
438                         }
439                 }
440
441                 [Test]
442                 public void SetLength ()
443                 {
444                         MemoryStream ms = new MemoryStream ();
445                         ms.Write (testStreamData, 0, 100);
446                         ms.Position = 100;
447                         ms.SetLength (150);
448                         AssertEquals ("#01", 150, ms.Length);
449                         AssertEquals ("#02", 100, ms.Position);
450                         ms.SetLength (80);
451                         AssertEquals ("#03", 80, ms.Length);
452                         AssertEquals ("#04", 80, ms.Position);
453                 }
454
455                 [Test]
456                 [ExpectedException (typeof (NotSupportedException))]
457                 public void SetLength_ReadOnly ()
458                 {
459                         MemoryStream ms = new MemoryStream (testStreamData, false);
460                         ms.SetLength (10);
461                 }
462
463                 [Test] // bug #327053
464                 [Category ("NotWorking")]
465                 public void ZeroingOnExpand ()
466                 {
467                         byte [] values = { 3, 2, 1 };
468                         byte [] reference = { 3, 2, 1 };
469                         byte [] cropped = { 3, 0, 0 };
470                         MemoryStream ms = new MemoryStream (values);
471                         Assert.AreEqual (values, reference, "#A1");
472                         ms.Seek (3, SeekOrigin.Begin);
473                         Assert.AreEqual (reference, values, "#A2");
474                         ms.SetLength (1);
475                         Assert.AreEqual (reference, values, "#B1");
476                         byte [] read = new byte [5];
477                         ms.Read (read, 0, 5);
478                         Assert.AreEqual (new byte [] { 0, 0, 0, 0, 0 }, read, "#B2");
479                         Assert.AreEqual (reference, values, "#B3");
480                         ms.SetLength (3);
481                         Assert.AreEqual (cropped, values, "#C1");
482                         ms.Seek (0, SeekOrigin.Begin);
483                         read = new byte [3];
484                         ms.Read (read, 0, 3);
485                         Assert.AreEqual (cropped, read, "#C2");
486                         Assert.AreEqual (cropped, values, "#C3");
487                 }
488
489                 [Test]
490                 [ExpectedException (typeof (NotSupportedException))]
491                 public void WriteNonWritable ()
492                 {
493                         MemoryStream ms = new MemoryStream (testStreamData, false);
494                         ms.Write (testStreamData, 0, 100);
495                 }
496
497                 [Test]
498                 [ExpectedException (typeof (NotSupportedException))]
499                 public void WriteExpand ()
500                 {
501                         MemoryStream ms = new MemoryStream (testStreamData);
502                         ms.Write (testStreamData, 0, 100);
503                         ms.Write (testStreamData, 0, 100); // This one throws the exception
504                 }
505
506                 [Test]
507                 public void WriteByte ()
508                 {
509                         MemoryStream ms = new MemoryStream (100);
510                         ms.Write (testStreamData, 0, 100);
511                         ms.Position = 100;
512                         ms.WriteByte (101);
513                         AssertEquals ("#01", 101, ms.Position);
514                         AssertEquals ("#02", 101, ms.Length);
515                         AssertEquals ("#03", 256, ms.Capacity);
516                         ms.Write (testStreamData, 0, 100);
517                         ms.Write (testStreamData, 0, 100);
518                         // 301
519                         AssertEquals ("#04", 301, ms.Position);
520                         AssertEquals ("#05", 301, ms.Length);
521                         AssertEquals ("#06", 512, ms.Capacity);
522                 }
523
524                 [Test]
525                 public void WriteLengths () {
526                         MemoryStream ms=new MemoryStream (256);
527                         BinaryWriter writer=new BinaryWriter (ms);
528
529                         writer.Write ((byte)'1');
530                         AssertEquals ("#01", 1, ms.Length);
531                         AssertEquals ("#02", 256, ms.Capacity);
532                         
533                         writer.Write ((ushort)0);
534                         AssertEquals ("#03", 3, ms.Length);
535                         AssertEquals ("#04", 256, ms.Capacity);
536
537                         writer.Write (testStreamData, 0, 23);
538                         AssertEquals ("#05", 26, ms.Length);
539                         AssertEquals ("#06", 256, ms.Capacity);
540
541                         writer.Write (testStreamData);
542                         writer.Write (testStreamData);
543                         writer.Write (testStreamData);
544                         AssertEquals ("#07", 326, ms.Length);
545                 }
546
547                 [Test]
548                 public void MoreWriteByte ()
549                 {
550                         byte[] buffer = new byte [44];
551                         
552                         MemoryStream ms = new MemoryStream (buffer);
553                         BinaryWriter bw = new BinaryWriter (ms);
554                         for(int i=0; i < 44; i++)
555                                 bw.Write ((byte) 1);
556                 }
557
558                 [Test]
559                 [ExpectedException (typeof (NotSupportedException))]
560                 public void MoreWriteByte2 ()
561                 {
562                         byte[] buffer = new byte [43]; // Note the 43 here
563                         
564                         MemoryStream ms = new MemoryStream (buffer);
565                         BinaryWriter bw = new BinaryWriter (ms);
566                         for(int i=0; i < 44; i++)
567                                 bw.Write ((byte) 1);
568                 }
569
570                 [Test]
571                 public void Expand () 
572                 {
573                         byte[] array = new byte [8] { 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01 };
574                         MemoryStream ms = new MemoryStream ();
575                         ms.Write (array, 0, array.Length);
576                         ms.SetLength (4);
577                         ms.Seek (4, SeekOrigin.End);
578                         ms.WriteByte (0xFF);
579                         Assert.AreEqual ("01-01-01-01-00-00-00-00-FF", BitConverter.ToString (ms.ToArray ()), "Result");
580                 }
581
582                 [Test]
583                 public void PubliclyVisible ()
584                 {
585                         MemoryStream ms = new MemoryStream ();
586                         Assert.IsNotNull (ms.GetBuffer (), "ctor()");
587
588                         ms = new MemoryStream (1);
589                         Assert.IsNotNull (ms.GetBuffer (), "ctor(1)");
590
591                         ms = new MemoryStream (new byte[1], 0, 1, true, true);
592                         Assert.IsNotNull (ms.GetBuffer (), "ctor(byte[],int,int,bool,bool");
593                 }
594
595                 [Test]
596                 [ExpectedException (typeof (UnauthorizedAccessException))]
597                 public void PubliclyVisible_Ctor_ByteArray ()
598                 {
599                         MemoryStream ms = new MemoryStream (new byte[0]);
600                         Assert.IsNotNull (ms.GetBuffer ());
601                 }
602
603                 [Test]
604                 [ExpectedException (typeof (UnauthorizedAccessException))]
605                 public void PubliclyVisible_Ctor_ByteArray_Boolean ()
606                 {
607                         MemoryStream ms = new MemoryStream (new byte[0], true);
608                         Assert.IsNotNull (ms.GetBuffer ());
609                 }
610
611                 [Test]
612                 [ExpectedException (typeof (UnauthorizedAccessException))]
613                 public void PubliclyVisible_Ctor_ByteArray_Int_Int ()
614                 {
615                         MemoryStream ms = new MemoryStream (new byte[1], 0, 1);
616                         Assert.IsNotNull (ms.GetBuffer ());
617                 }
618
619                 [Test]
620                 [ExpectedException (typeof (UnauthorizedAccessException))]
621                 public void PubliclyVisible_Ctor_ByteArray_Int_Int_Boolean ()
622                 {
623                         MemoryStream ms = new MemoryStream (new byte[1], 0, 1, true);
624                         Assert.IsNotNull (ms.GetBuffer ());
625                 }
626
627                 [Test]
628                 [ExpectedException (typeof (UnauthorizedAccessException))]
629                 public void PubliclyVisible_Ctor_ByteArray_Int_Int_Boolean_Boolean ()
630                 {
631                         MemoryStream ms = new MemoryStream (new byte[1], 0, 1, true, false);
632                         Assert.IsNotNull (ms.GetBuffer ());
633                 }
634
635                 [Test] // bug #80205
636                 [Category ("NotWorking")]
637                 public void SerializeTest ()
638                 {
639                         MemoryStream input = new MemoryStream ();
640                         byte [] bufferIn = Encoding.UTF8.GetBytes ("some test");
641                         input.Write (bufferIn, 0, bufferIn.Length);
642                         input.Position = 0;
643
644                         BinaryFormatter bf = new BinaryFormatter ();
645                         MemoryStream ms = new MemoryStream ();
646                         bf.Serialize (ms, input);
647
648                         byte [] bufferOut = new byte [ms.Length];
649                         ms.Position = 0;
650                         ms.Read (bufferOut, 0, bufferOut.Length);
651
652                         Assert.AreEqual (_serialized, bufferOut);
653                 }
654
655                 [Test] // bug #80205
656                 [Category ("NotWorking")]
657                 public void DeserializeTest ()
658                 {
659                         MemoryStream ms = new MemoryStream ();
660                         ms.Write (_serialized, 0, _serialized.Length);
661                         ms.Position = 0;
662
663                         BinaryFormatter bf = new BinaryFormatter ();
664                         MemoryStream output = (MemoryStream) bf.Deserialize (ms);
665                         using (StreamReader sr = new StreamReader (output)) {
666                                 Assert.AreEqual ("some test", sr.ReadToEnd ());
667                         }
668                 }
669
670                 private static byte [] _serialized = new byte [] {
671                         0x00, 0x01, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x01, 0x00,
672                         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x01, 0x00, 0x00, 0x00,
673                         0x16, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x49, 0x4f, 0x2e,
674                         0x4d, 0x65, 0x6d, 0x6f, 0x72, 0x79, 0x53, 0x74, 0x72, 0x65, 0x61,
675                         0x6d, 0x0a, 0x00, 0x00, 0x00, 0x07, 0x5f, 0x62, 0x75, 0x66, 0x66,
676                         0x65, 0x72, 0x07, 0x5f, 0x6f, 0x72, 0x69, 0x67, 0x69, 0x6e, 0x09,
677                         0x5f, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x07, 0x5f,
678                         0x6c, 0x65, 0x6e, 0x67, 0x74, 0x68, 0x09, 0x5f, 0x63, 0x61, 0x70,
679                         0x61, 0x63, 0x69, 0x74, 0x79, 0x0b, 0x5f, 0x65, 0x78, 0x70, 0x61,
680                         0x6e, 0x64, 0x61, 0x62, 0x6c, 0x65, 0x09, 0x5f, 0x77, 0x72, 0x69,
681                         0x74, 0x61, 0x62, 0x6c, 0x65, 0x0a, 0x5f, 0x65, 0x78, 0x70, 0x6f,
682                         0x73, 0x61, 0x62, 0x6c, 0x65, 0x07, 0x5f, 0x69, 0x73, 0x4f, 0x70,
683                         0x65, 0x6e, 0x1d, 0x4d, 0x61, 0x72, 0x73, 0x68, 0x61, 0x6c, 0x42,
684                         0x79, 0x52, 0x65, 0x66, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x2b,
685                         0x5f, 0x5f, 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x07,
686                         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x02, 0x08,
687                         0x08, 0x08, 0x08, 0x01, 0x01, 0x01, 0x01, 0x09, 0x02, 0x00, 0x00,
688                         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09, 0x00,
689                         0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x0a,
690                         0x0f, 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x02, 0x73,
691                         0x6f, 0x6d, 0x65, 0x20, 0x74, 0x65, 0x73, 0x74, 0x00, 0x00, 0x00,
692                         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
693                         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
694                         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
695                         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
696                         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
697                         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
698                         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
699                         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
700                         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
701                         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
702                         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
703                         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
704                         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
705                         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
706                         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
707                         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
708                         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
709                         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
710                         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
711                         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
712                         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
713                         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
714                         0x00, 0x00, 0x0b };
715 #if NET_2_0
716                 class MyMemoryStream : MemoryStream {
717
718                         public bool DisposedCalled = false;
719
720                         protected override void Dispose(bool disposing)
721                         {
722                                 DisposedCalled = true;
723                         }
724                 }
725
726                 [Test] // https://bugzilla.novell.com/show_bug.cgi?id=322672
727                 public void BaseDisposeCalled ()
728                 {
729                         MyMemoryStream ms = new MyMemoryStream ();
730                         Assert.IsFalse (ms.DisposedCalled, "Before");
731                         ms.Close ();
732                         Assert.IsTrue (ms.DisposedCalled, "After");
733                 }
734 #endif
735         }
736 }