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"
                                          );
        }
        public virtual void TestSmallObjectLoader()
        {
            byte[]       act = GetRng().NextBytes(512);
            ObjectLoader ldr = new ObjectLoader.SmallObject(Constants.OBJ_BLOB, act);

            NUnit.Framework.Assert.AreEqual(Constants.OBJ_BLOB, ldr.GetType());
            NUnit.Framework.Assert.AreEqual(act.Length, ldr.GetSize());
            NUnit.Framework.Assert.IsFalse(ldr.IsLarge(), "not is large");
            NUnit.Framework.Assert.AreSame(act, ldr.GetCachedBytes());
            NUnit.Framework.Assert.AreSame(act, ldr.GetCachedBytes(1));
            NUnit.Framework.Assert.AreSame(act, ldr.GetCachedBytes(int.MaxValue));
            byte[] copy = ldr.GetBytes();
            NUnit.Framework.Assert.AreNotSame(act, copy);
            NUnit.Framework.Assert.IsTrue(Arrays.Equals(act, copy), "same content");
            copy = ldr.GetBytes(1);
            NUnit.Framework.Assert.AreNotSame(act, copy);
            NUnit.Framework.Assert.IsTrue(Arrays.Equals(act, copy), "same content");
            copy = ldr.GetBytes(int.MaxValue);
            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.IsTrue(@in is ObjectStream.SmallStream, "is small 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"
                                          );
        }