In Test/System.IO:
[mono.git] / mcs / class / corlib / Test / System.IO / MemoryStreamTest.cs
index c2883aa82bc13ae1fcbfeb438f7ffbb3bab919c6..88ad55cab9f50c9be11458b5f4a04a4728c4495f 100644 (file)
@@ -1,18 +1,22 @@
 //
-// System.IO.StringWriter
+// System.IO.MemoryStreamTest
 //
 // Authors:
 //     Marcin Szczepanski (marcins@zipworld.com.au)
 //     Gonzalo Paniagua Javier (gonzalo@ximian.com)
+//     Sebastien Pouliot  <sebastien@ximian.com>
 //
 // (c) 2003 Ximian, Inc. (http://www.ximian.com)
+// Copyright (C) 2004 Novell (http://www.novell.com)
 //
 
-using NUnit.Framework;
-using System.IO;
 using System;
+using System.IO;
+using System.Runtime.Serialization.Formatters.Binary;
 using System.Text;
 
+using NUnit.Framework;
+
 namespace MonoTests.System.IO
 {
        [TestFixture]
@@ -22,7 +26,7 @@ namespace MonoTests.System.IO
                byte [] testStreamData;
 
                [SetUp]
-               void SetUp ()
+               public void SetUp ()
                {
                        testStreamData = new byte [100];
 
@@ -39,7 +43,7 @@ namespace MonoTests.System.IO
                void VerifyTestData (string id, byte [] testBytes, int start, int count)
                {
                        if (testBytes == null)
-                               Assertion.Fail (id + "+1 testBytes is null");
+                               Assert.Fail (id + "+1 testBytes is null");
 
                        if (start < 0 ||
                            count < 0  ||
@@ -57,18 +61,33 @@ namespace MonoTests.System.IO
                                                        start + test,
                                                        testBytes [test],
                                                        testStreamData [start + test]);
-                               Assertion.Fail (id + "-3" + failStr);
+                               Assert.Fail (id + "-3" + failStr);
                        }
                }
 
+               public void AssertEquals (string message, int expected, int actual)
+               {
+                       Assert.AreEqual (expected, actual, message);
+               }
+
+               public void AssertEquals (string message, long expected, long actual)
+               {
+                       Assert.AreEqual (expected, actual, message);
+               }
+
+               public void AssertEquals (string message, bool expected, bool actual)
+               {
+                       Assert.AreEqual (expected, actual, message);
+               }
+
                [Test]
                public void ConstructorsOne ()
                {
                        MemoryStream ms = new MemoryStream();
 
-                       Assertion.AssertEquals ("#01", 0L, ms.Length);
-                       Assertion.AssertEquals ("#02", 0, ms.Capacity);
-                       Assertion.AssertEquals ("#03", true, ms.CanWrite);
+                       AssertEquals ("#01", 0L, ms.Length);
+                       AssertEquals ("#02", 0, ms.Capacity);
+                       AssertEquals ("#03", true, ms.CanWrite);
                }
 
                [Test]
@@ -76,16 +95,16 @@ namespace MonoTests.System.IO
                {
                        MemoryStream ms = new MemoryStream (10);
 
-                       Assertion.AssertEquals ("#01", 0L, ms.Length);
-                       Assertion.AssertEquals ("#02", 10, ms.Capacity);
+                       AssertEquals ("#01", 0L, ms.Length);
+                       AssertEquals ("#02", 10, ms.Capacity);
                        ms.Capacity = 0;
                        byte [] buffer = ms.GetBuffer ();
                        // Begin: wow!!!
-                       Assertion.AssertEquals ("#03", -1, ms.ReadByte ());
-                       Assertion.AssertEquals ("#04", null, buffer); // <--
+                       AssertEquals ("#03", -1, ms.ReadByte ());
+                       Assert.IsNull (buffer, "#04"); // <--
                        ms.Read (new byte [5], 0, 5);
-                       Assertion.AssertEquals ("#05", 0, ms.Position);
-                       Assertion.AssertEquals ("#06", 0, ms.Length);
+                       AssertEquals ("#05", 0, ms.Position);
+                       AssertEquals ("#06", 0, ms.Length);
                        // End
                }
 
@@ -93,21 +112,21 @@ namespace MonoTests.System.IO
                public void ConstructorsThree ()
                {
                        MemoryStream ms = new MemoryStream (testStreamData);
-                       Assertion.AssertEquals ("#01", 100, ms.Length);
-                       Assertion.AssertEquals ("#02", 0, ms.Position);
+                       AssertEquals ("#01", 100, ms.Length);
+                       AssertEquals ("#02", 0, ms.Position);
                }
 
                [Test]
                public void ConstructorsFour ()
                {
                        MemoryStream ms = new MemoryStream (testStreamData, true);
-                       Assertion.AssertEquals ("#01", 100, ms.Length);
-                       Assertion.AssertEquals ("#02", 0, ms.Position);
+                       AssertEquals ("#01", 100, ms.Length);
+                       AssertEquals ("#02", 0, ms.Position);
                        ms.Position = 50;
                        byte saved = testStreamData [50];
                        try {
                                ms.WriteByte (23);
-                               Assertion.AssertEquals ("#03", testStreamData [50], 23);
+                               AssertEquals ("#03", testStreamData [50], 23);
                        } finally {
                                testStreamData [50] = saved;
                        }
@@ -117,21 +136,21 @@ namespace MonoTests.System.IO
                        } catch (Exception) {
                                return;
                        }
-                       Assertion.Fail ("#04");
+                       Assert.Fail ("#04");
                }
 
                [Test]
                public void ConstructorsFive ()
                {
                        MemoryStream ms = new MemoryStream (testStreamData, 50, 50);
-                       Assertion.AssertEquals ("#01", 50, ms.Length);
-                       Assertion.AssertEquals ("#02", 0, ms.Position);
-                       Assertion.AssertEquals ("#03", 50, ms.Capacity);
+                       AssertEquals ("#01", 50, ms.Length);
+                       AssertEquals ("#02", 0, ms.Position);
+                       AssertEquals ("#03", 50, ms.Capacity);
                        ms.Position = 1;
                        byte saved = testStreamData [51];
                        try {
                                ms.WriteByte (23);
-                               Assertion.AssertEquals ("#04", testStreamData [51], 23);
+                               AssertEquals ("#04", testStreamData [51], 23);
                        } finally {
                                testStreamData [51] = saved;
                        }
@@ -144,17 +163,7 @@ namespace MonoTests.System.IO
                        }
 
                        if (!gotException)
-                               Assertion.Fail ("#05");
-
-                       gotException = false;
-                       try {
-                               ms.GetBuffer ();
-                       } catch (UnauthorizedAccessException) {
-                               gotException = true;
-                       }
-
-                       if (!gotException)
-                               Assertion.Fail ("#06");
+                               Assert.Fail ("#05");
 
                        ms.Capacity = 100; // Allowed. It's the same as the one in the ms.
                                           // This is lame, as the length is 50!!!
@@ -167,9 +176,9 @@ namespace MonoTests.System.IO
                        }
 
                        if (!gotException)
-                               Assertion.Fail ("#07");
+                               Assert.Fail ("#07");
 
-                       Assertion.AssertEquals ("#08", 50, ms.ToArray ().Length);
+                       AssertEquals ("#08", 50, ms.ToArray ().Length);
                }
 
                [Test]
@@ -202,7 +211,7 @@ namespace MonoTests.System.IO
                        VerifyTestData ("R3", readBytes, 80, 20);
 
                        int readByte = testStream.ReadByte();
-                       Assertion.AssertEquals (-1, readByte);
+                       Assert.AreEqual (-1, readByte, "R4");
                }
 
                [Test]
@@ -218,7 +227,7 @@ namespace MonoTests.System.IO
                        ms.Seek (0, SeekOrigin.Begin); 
                        testStream.Read (readBytes, 0, 100);
                        VerifyTestData ("W1", readBytes, 0, 100);
-               }               
+               }
 
                [Test]
                public void WriteBlock ()
@@ -232,7 +241,7 @@ namespace MonoTests.System.IO
                        testStream.Read (readBytes, 0, 100);
                        VerifyTestData ("WB1", readBytes, 0, 100);
                        byte[] arrayBytes = testStream.ToArray();
-                       Assertion.AssertEquals ("#01", 100, arrayBytes.Length);
+                       AssertEquals ("#01", 100, arrayBytes.Length);
                        VerifyTestData ("WB2", arrayBytes, 0, 100);
                }
 
@@ -243,10 +252,10 @@ namespace MonoTests.System.IO
                        ms.Position = 4;
                        ms.WriteByte ((byte) 'M');
                        ms.WriteByte ((byte) 'O');
-                       Assertion.AssertEquals ("#01", 6, ms.Length);
-                       Assertion.AssertEquals ("#02", 6, ms.Position);
+                       AssertEquals ("#01", 6, ms.Length);
+                       AssertEquals ("#02", 6, ms.Position);
                        ms.Position = 0;
-                       Assertion.AssertEquals ("#03", 0, ms.Position);
+                       AssertEquals ("#03", 0, ms.Position);
                }
 
                [Test]
@@ -255,8 +264,8 @@ namespace MonoTests.System.IO
                {
                        MemoryStream ms = new MemoryStream (testStreamData);
                        ms.Position = 101;
-                       Assertion.AssertEquals ("#01", 101, ms.Position);
-                       Assertion.AssertEquals ("#02", 100, ms.Length);
+                       AssertEquals ("#01", 101, ms.Position);
+                       AssertEquals ("#02", 100, ms.Length);
                        ms.WriteByte (1); // This should throw the exception
                }
 
@@ -265,7 +274,7 @@ namespace MonoTests.System.IO
                {
                        MemoryStream ms = new MemoryStream ();
                        byte [] buffer = ms.GetBuffer ();
-                       Assertion.AssertEquals ("#01", 0, buffer.Length);
+                       AssertEquals ("#01", 0, buffer.Length);
                }
 
                [Test]
@@ -273,13 +282,13 @@ namespace MonoTests.System.IO
                {
                        MemoryStream ms = new MemoryStream (100);
                        byte [] buffer = ms.GetBuffer ();
-                       Assertion.AssertEquals ("#01", 100, buffer.Length);
+                       AssertEquals ("#01", 100, buffer.Length);
 
                        ms.Write (testStreamData, 0, 100);
                        ms.Write (testStreamData, 0, 100);
-                       Assertion.AssertEquals ("#02", 200, ms.Length);
+                       AssertEquals ("#02", 200, ms.Length);
                        buffer = ms.GetBuffer ();
-                       Assertion.AssertEquals ("#03", 256, buffer.Length); // Minimun size after writing
+                       AssertEquals ("#03", 256, buffer.Length); // Minimun size after writing
                }
 
                [Test]
@@ -295,7 +304,7 @@ namespace MonoTests.System.IO
                        }
 
                        if (!thrown)
-                               Assertion.Fail ("#01");
+                               Assert.Fail ("#01");
 
                        thrown = false;
                        try {
@@ -305,7 +314,7 @@ namespace MonoTests.System.IO
                        }
 
                        if (!thrown)
-                               Assertion.Fail ("#02");
+                               Assert.Fail ("#02");
 
                        // The first exception thrown is ObjectDisposed, not ArgumentNull
                        thrown = false;
@@ -316,7 +325,7 @@ namespace MonoTests.System.IO
                        }
 
                        if (!thrown)
-                               Assertion.Fail ("#03");
+                               Assert.Fail ("#03");
 
                        thrown = false;
                        try {
@@ -326,7 +335,34 @@ namespace MonoTests.System.IO
                        }
 
                        if (!thrown)
-                               Assertion.Fail ("#03");
+                               Assert.Fail ("#03");
+               }
+
+               [Test]
+               [ExpectedException (typeof (ObjectDisposedException))]
+               public void Close_get_Length () 
+               {
+                       MemoryStream ms = new MemoryStream (100);
+                       ms.Close ();
+                       long x = ms.Length;
+               }
+
+               [Test]
+               [ExpectedException (typeof (ObjectDisposedException))]
+               public void Close_get_Position () 
+               {
+                       MemoryStream ms = new MemoryStream (100);
+                       ms.Close ();
+                       long x = ms.Position;
+               }
+
+               [Test]
+               [ExpectedException (typeof (ObjectDisposedException))]
+               public void Close_set_Position () 
+               {
+                       MemoryStream ms = new MemoryStream (100);
+                       ms.Close ();
+                       ms.Position = 0;
                }
 
                [Test]
@@ -347,7 +383,7 @@ namespace MonoTests.System.IO
                                thrown = true;
                        }
                        if (!thrown)
-                               Assertion.Fail ("#01");
+                               Assert.Fail ("#01");
                        
                        thrown = false;
                        try {
@@ -357,7 +393,7 @@ namespace MonoTests.System.IO
                        }
 
                        if (!thrown)
-                               Assertion.Fail ("#02");
+                               Assert.Fail ("#02");
 
                        thrown=false;
                        try {
@@ -368,26 +404,38 @@ namespace MonoTests.System.IO
                        }
 
                        if (!thrown)
-                               Assertion.Fail ("#03");
+                               Assert.Fail ("#03");
 
                        ms=new MemoryStream (256);
 
                        ms.Write (testStreamData, 0, 100);
                        ms.Position=0;
-                       Assertion.AssertEquals ("#01", 100, ms.Length);
-                       Assertion.AssertEquals ("#02", 0, ms.Position);
+                       AssertEquals ("#01", 100, ms.Length);
+                       AssertEquals ("#02", 0, ms.Position);
 
                        ms.Position=128;
-                       Assertion.AssertEquals ("#03", 100, ms.Length);
-                       Assertion.AssertEquals ("#04", 128, ms.Position);
+                       AssertEquals ("#03", 100, ms.Length);
+                       AssertEquals ("#04", 128, ms.Position);
 
                        ms.Position=768;
-                       Assertion.AssertEquals ("#05", 100, ms.Length);
-                       Assertion.AssertEquals ("#06", 768, ms.Position);
+                       AssertEquals ("#05", 100, ms.Length);
+                       AssertEquals ("#06", 768, ms.Position);
 
                        ms.WriteByte (0);
-                       Assertion.AssertEquals ("#07", 769, ms.Length);
-                       Assertion.AssertEquals ("#08", 769, ms.Position);
+                       AssertEquals ("#07", 769, ms.Length);
+                       AssertEquals ("#08", 769, ms.Position);
+               }
+
+               [Test]
+               public void Seek_Disposed () 
+               {
+                       MemoryStream ms = new MemoryStream ();
+                       ms.Close ();
+                       try {
+                               ms.Seek (0, SeekOrigin.Begin);
+                               Assert.Fail ();
+                       } catch (ObjectDisposedException) {
+                       }
                }
 
                [Test]
@@ -397,11 +445,45 @@ namespace MonoTests.System.IO
                        ms.Write (testStreamData, 0, 100);
                        ms.Position = 100;
                        ms.SetLength (150);
-                       Assertion.AssertEquals ("#01", 150, ms.Length);
-                       Assertion.AssertEquals ("#02", 100, ms.Position);
+                       AssertEquals ("#01", 150, ms.Length);
+                       AssertEquals ("#02", 100, ms.Position);
                        ms.SetLength (80);
-                       Assertion.AssertEquals ("#03", 80, ms.Length);
-                       Assertion.AssertEquals ("#04", 80, ms.Position);
+                       AssertEquals ("#03", 80, ms.Length);
+                       AssertEquals ("#04", 80, ms.Position);
+               }
+
+               [Test]
+               [ExpectedException (typeof (NotSupportedException))]
+               public void SetLength_ReadOnly ()
+               {
+                       MemoryStream ms = new MemoryStream (testStreamData, false);
+                       ms.SetLength (10);
+               }
+
+               [Test] // bug #327053
+               [Category ("NotWorking")]
+               public void ZeroingOnExpand ()
+               {
+                       byte [] values = { 3, 2, 1 };
+                       byte [] reference = { 3, 2, 1 };
+                       byte [] cropped = { 3, 0, 0 };
+                       MemoryStream ms = new MemoryStream (values);
+                       Assert.AreEqual (values, reference, "#A1");
+                       ms.Seek (3, SeekOrigin.Begin);
+                       Assert.AreEqual (reference, values, "#A2");
+                       ms.SetLength (1);
+                       Assert.AreEqual (reference, values, "#B1");
+                       byte [] read = new byte [5];
+                       ms.Read (read, 0, 5);
+                       Assert.AreEqual (new byte [] { 0, 0, 0, 0, 0 }, read, "#B2");
+                       Assert.AreEqual (reference, values, "#B3");
+                       ms.SetLength (3);
+                       Assert.AreEqual (cropped, values, "#C1");
+                       ms.Seek (0, SeekOrigin.Begin);
+                       read = new byte [3];
+                       ms.Read (read, 0, 3);
+                       Assert.AreEqual (cropped, read, "#C2");
+                       Assert.AreEqual (cropped, values, "#C3");
                }
 
                [Test]
@@ -428,15 +510,15 @@ namespace MonoTests.System.IO
                        ms.Write (testStreamData, 0, 100);
                        ms.Position = 100;
                        ms.WriteByte (101);
-                       Assertion.AssertEquals ("#01", 101, ms.Position);
-                       Assertion.AssertEquals ("#02", 101, ms.Length);
-                       Assertion.AssertEquals ("#03", 256, ms.Capacity);
+                       AssertEquals ("#01", 101, ms.Position);
+                       AssertEquals ("#02", 101, ms.Length);
+                       AssertEquals ("#03", 256, ms.Capacity);
                        ms.Write (testStreamData, 0, 100);
                        ms.Write (testStreamData, 0, 100);
                        // 301
-                       Assertion.AssertEquals ("#04", 301, ms.Position);
-                       Assertion.AssertEquals ("#05", 301, ms.Length);
-                       Assertion.AssertEquals ("#06", 512, ms.Capacity);
+                       AssertEquals ("#04", 301, ms.Position);
+                       AssertEquals ("#05", 301, ms.Length);
+                       AssertEquals ("#06", 512, ms.Capacity);
                }
 
                [Test]
@@ -445,22 +527,218 @@ namespace MonoTests.System.IO
                        BinaryWriter writer=new BinaryWriter (ms);
 
                        writer.Write ((byte)'1');
-                       Assertion.AssertEquals ("#01", 1, ms.Length);
-                       Assertion.AssertEquals ("#02", 256, ms.Capacity);
+                       AssertEquals ("#01", 1, ms.Length);
+                       AssertEquals ("#02", 256, ms.Capacity);
                        
                        writer.Write ((ushort)0);
-                       Assertion.AssertEquals ("#03", 3, ms.Length);
-                       Assertion.AssertEquals ("#04", 256, ms.Capacity);
+                       AssertEquals ("#03", 3, ms.Length);
+                       AssertEquals ("#04", 256, ms.Capacity);
 
                        writer.Write (testStreamData, 0, 23);
-                       Assertion.AssertEquals ("#05", 26, ms.Length);
-                       Assertion.AssertEquals ("#06", 256, ms.Capacity);
+                       AssertEquals ("#05", 26, ms.Length);
+                       AssertEquals ("#06", 256, ms.Capacity);
 
                        writer.Write (testStreamData);
                        writer.Write (testStreamData);
                        writer.Write (testStreamData);
-                       Assertion.AssertEquals ("#07", 326, ms.Length);
+                       AssertEquals ("#07", 326, ms.Length);
+               }
+
+               [Test]
+               public void MoreWriteByte ()
+               {
+                       byte[] buffer = new byte [44];
+                       
+                       MemoryStream ms = new MemoryStream (buffer);
+                       BinaryWriter bw = new BinaryWriter (ms);
+                       for(int i=0; i < 44; i++)
+                               bw.Write ((byte) 1);
                }
+
+               [Test]
+               [ExpectedException (typeof (NotSupportedException))]
+               public void MoreWriteByte2 ()
+               {
+                       byte[] buffer = new byte [43]; // Note the 43 here
+                       
+                       MemoryStream ms = new MemoryStream (buffer);
+                       BinaryWriter bw = new BinaryWriter (ms);
+                       for(int i=0; i < 44; i++)
+                               bw.Write ((byte) 1);
+               }
+
+               [Test]
+               public void Expand () 
+               {
+                       byte[] array = new byte [8] { 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01 };
+                       MemoryStream ms = new MemoryStream ();
+                       ms.Write (array, 0, array.Length);
+                       ms.SetLength (4);
+                       ms.Seek (4, SeekOrigin.End);
+                       ms.WriteByte (0xFF);
+                       Assert.AreEqual ("01-01-01-01-00-00-00-00-FF", BitConverter.ToString (ms.ToArray ()), "Result");
+               }
+
+               [Test]
+               public void PubliclyVisible ()
+               {
+                       MemoryStream ms = new MemoryStream ();
+                       Assert.IsNotNull (ms.GetBuffer (), "ctor()");
+
+                       ms = new MemoryStream (1);
+                       Assert.IsNotNull (ms.GetBuffer (), "ctor(1)");
+
+                       ms = new MemoryStream (new byte[1], 0, 1, true, true);
+                       Assert.IsNotNull (ms.GetBuffer (), "ctor(byte[],int,int,bool,bool");
+               }
+
+               [Test]
+               [ExpectedException (typeof (UnauthorizedAccessException))]
+               public void PubliclyVisible_Ctor_ByteArray ()
+               {
+                       MemoryStream ms = new MemoryStream (new byte[0]);
+                       Assert.IsNotNull (ms.GetBuffer ());
+               }
+
+               [Test]
+               [ExpectedException (typeof (UnauthorizedAccessException))]
+               public void PubliclyVisible_Ctor_ByteArray_Boolean ()
+               {
+                       MemoryStream ms = new MemoryStream (new byte[0], true);
+                       Assert.IsNotNull (ms.GetBuffer ());
+               }
+
+               [Test]
+               [ExpectedException (typeof (UnauthorizedAccessException))]
+               public void PubliclyVisible_Ctor_ByteArray_Int_Int ()
+               {
+                       MemoryStream ms = new MemoryStream (new byte[1], 0, 1);
+                       Assert.IsNotNull (ms.GetBuffer ());
+               }
+
+               [Test]
+               [ExpectedException (typeof (UnauthorizedAccessException))]
+               public void PubliclyVisible_Ctor_ByteArray_Int_Int_Boolean ()
+               {
+                       MemoryStream ms = new MemoryStream (new byte[1], 0, 1, true);
+                       Assert.IsNotNull (ms.GetBuffer ());
+               }
+
+               [Test]
+               [ExpectedException (typeof (UnauthorizedAccessException))]
+               public void PubliclyVisible_Ctor_ByteArray_Int_Int_Boolean_Boolean ()
+               {
+                       MemoryStream ms = new MemoryStream (new byte[1], 0, 1, true, false);
+                       Assert.IsNotNull (ms.GetBuffer ());
+               }
+
+               [Test] // bug #350860
+               public void ToArray_Empty ()
+               {
+                       MemoryStream ms = new MemoryStream (1);
+                       ms.Capacity = 0;
+                       ms.ToArray ();
+               }
+
+               [Test] // bug #80205
+               [Category ("NotWorking")]
+               public void SerializeTest ()
+               {
+                       MemoryStream input = new MemoryStream ();
+                       byte [] bufferIn = Encoding.UTF8.GetBytes ("some test");
+                       input.Write (bufferIn, 0, bufferIn.Length);
+                       input.Position = 0;
+
+                       BinaryFormatter bf = new BinaryFormatter ();
+                       MemoryStream ms = new MemoryStream ();
+                       bf.Serialize (ms, input);
+
+                       byte [] bufferOut = new byte [ms.Length];
+                       ms.Position = 0;
+                       ms.Read (bufferOut, 0, bufferOut.Length);
+
+                       Assert.AreEqual (_serialized, bufferOut);
+               }
+
+               [Test] // bug #80205
+               [Category ("NotWorking")]
+               public void DeserializeTest ()
+               {
+                       MemoryStream ms = new MemoryStream ();
+                       ms.Write (_serialized, 0, _serialized.Length);
+                       ms.Position = 0;
+
+                       BinaryFormatter bf = new BinaryFormatter ();
+                       MemoryStream output = (MemoryStream) bf.Deserialize (ms);
+                       using (StreamReader sr = new StreamReader (output)) {
+                               Assert.AreEqual ("some test", sr.ReadToEnd ());
+                       }
+               }
+
+               private static byte [] _serialized = new byte [] {
+                       0x00, 0x01, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x01, 0x00,
+                       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x01, 0x00, 0x00, 0x00,
+                       0x16, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x49, 0x4f, 0x2e,
+                       0x4d, 0x65, 0x6d, 0x6f, 0x72, 0x79, 0x53, 0x74, 0x72, 0x65, 0x61,
+                       0x6d, 0x0a, 0x00, 0x00, 0x00, 0x07, 0x5f, 0x62, 0x75, 0x66, 0x66,
+                       0x65, 0x72, 0x07, 0x5f, 0x6f, 0x72, 0x69, 0x67, 0x69, 0x6e, 0x09,
+                       0x5f, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x07, 0x5f,
+                       0x6c, 0x65, 0x6e, 0x67, 0x74, 0x68, 0x09, 0x5f, 0x63, 0x61, 0x70,
+                       0x61, 0x63, 0x69, 0x74, 0x79, 0x0b, 0x5f, 0x65, 0x78, 0x70, 0x61,
+                       0x6e, 0x64, 0x61, 0x62, 0x6c, 0x65, 0x09, 0x5f, 0x77, 0x72, 0x69,
+                       0x74, 0x61, 0x62, 0x6c, 0x65, 0x0a, 0x5f, 0x65, 0x78, 0x70, 0x6f,
+                       0x73, 0x61, 0x62, 0x6c, 0x65, 0x07, 0x5f, 0x69, 0x73, 0x4f, 0x70,
+                       0x65, 0x6e, 0x1d, 0x4d, 0x61, 0x72, 0x73, 0x68, 0x61, 0x6c, 0x42,
+                       0x79, 0x52, 0x65, 0x66, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x2b,
+                       0x5f, 0x5f, 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x07,
+                       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x02, 0x08,
+                       0x08, 0x08, 0x08, 0x01, 0x01, 0x01, 0x01, 0x09, 0x02, 0x00, 0x00,
+                       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09, 0x00,
+                       0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x0a,
+                       0x0f, 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x02, 0x73,
+                       0x6f, 0x6d, 0x65, 0x20, 0x74, 0x65, 0x73, 0x74, 0x00, 0x00, 0x00,
+                       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+                       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+                       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+                       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+                       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+                       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+                       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+                       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+                       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+                       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+                       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+                       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+                       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+                       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+                       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+                       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+                       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+                       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+                       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+                       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+                       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+                       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+                       0x00, 0x00, 0x0b };
+#if NET_2_0
+               class MyMemoryStream : MemoryStream {
+
+                       public bool DisposedCalled = false;
+
+                       protected override void Dispose(bool disposing)
+                       {
+                               DisposedCalled = true;
+                       }
+               }
+
+               [Test] // https://bugzilla.novell.com/show_bug.cgi?id=322672
+               public void BaseDisposeCalled ()
+               {
+                       MyMemoryStream ms = new MyMemoryStream ();
+                       Assert.IsFalse (ms.DisposedCalled, "Before");
+                       ms.Close ();
+                       Assert.IsTrue (ms.DisposedCalled, "After");
+               }
+#endif
        }
 }
-