public virtual void TestLargeObjectLoader() { byte[] act = GetRng().NextBytes(512); ObjectLoader ldr = new _ObjectLoader_122(act); NUnit.Framework.Assert.AreEqual(Constants.OBJ_BLOB, ldr.GetType()); NUnit.Framework.Assert.AreEqual(act.Length, ldr.GetSize()); NUnit.Framework.Assert.IsTrue(ldr.IsLarge(), "is large"); try { ldr.GetCachedBytes(); NUnit.Framework.Assert.Fail("did not throw on getCachedBytes()"); } catch (LargeObjectException) { } // expected try { ldr.GetBytes(); NUnit.Framework.Assert.Fail("did not throw on getBytes()"); } catch (LargeObjectException) { } // expected try { ldr.GetCachedBytes(64); NUnit.Framework.Assert.Fail("did not throw on getCachedBytes(64)"); } catch (LargeObjectException) { } // expected byte[] copy = ldr.GetCachedBytes(1024); NUnit.Framework.Assert.AreNotSame(act, copy); NUnit.Framework.Assert.IsTrue(Arrays.Equals(act, copy), "same content"); ObjectStream @in = ldr.OpenStream(); NUnit.Framework.Assert.IsNotNull(@in, "has stream"); NUnit.Framework.Assert.AreEqual(Constants.OBJ_BLOB, @in.GetType()); NUnit.Framework.Assert.AreEqual(act.Length, @in.GetSize()); NUnit.Framework.Assert.AreEqual(act.Length, @in.Available()); NUnit.Framework.Assert.IsTrue(@in.MarkSupported(), "mark supported"); copy = new byte[act.Length]; NUnit.Framework.Assert.AreEqual(act.Length, @in.Read(copy)); NUnit.Framework.Assert.AreEqual(0, @in.Available()); NUnit.Framework.Assert.AreEqual(-1, @in.Read()); NUnit.Framework.Assert.IsTrue(Arrays.Equals(act, copy), "same content"); ByteArrayOutputStream tmp = new ByteArrayOutputStream(); ldr.CopyTo(tmp); NUnit.Framework.Assert.IsTrue(Arrays.Equals(act, tmp.ToByteArray()), "same content" ); }