ms.Seek (0, SeekOrigin.Begin);
testStream.Read (readBytes, 0, 100);
VerifyTestData ("W1", readBytes, 0, 100);
- }
+ }
[Test]
public void WriteBlock ()
}
[Test]
- [ExpectedException (typeof (ObjectDisposedException))]
public void Seek_Disposed ()
{
MemoryStream ms = new MemoryStream ();
ms.Close ();
- ms.Seek (0, SeekOrigin.Begin);
+ try {
+ ms.Seek (0, SeekOrigin.Begin);
+ Assert.Fail ();
+ } catch (ObjectDisposedException) {
+ }
}
[Test]
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]
[ExpectedException (typeof (NotSupportedException))]
public void WriteNonWritable ()
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 ()
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
}
}
-