ReadObject() public method

public ReadObject ( ) : Object
return Object
 public void TestClearBody()
 {
     ActiveMQStreamMessage streamMessage = new ActiveMQStreamMessage();
     try
     {
         streamMessage.WriteObject((Int64) 2);
         streamMessage.ClearBody();
         Assert.IsFalse(streamMessage.ReadOnlyBody);
         streamMessage.WriteObject((Int64) 2);
         streamMessage.ReadObject();
         Assert.Fail("should throw exception");
     }
     catch(MessageNotReadableException)
     {
     }
     catch(MessageNotWriteableException)
     {
         Assert.Fail("should be writeable");
     }
 }
        public void TestReadObject()
        {
            ActiveMQStreamMessage msg = new ActiveMQStreamMessage();
            byte testByte = (byte)2;
            msg.WriteByte(testByte);
            msg.Reset();
            Assert.IsTrue((byte)msg.ReadObject() == testByte);
            msg.ClearBody();

            short testShort = 3;
            msg.WriteInt16(testShort);
            msg.Reset();
            Assert.IsTrue((short)msg.ReadObject() == testShort);
            msg.ClearBody();

            int testInt = 4;
            msg.WriteInt32(testInt);
            msg.Reset();
            Assert.IsTrue((int)msg.ReadObject() == testInt);
            msg.ClearBody();

            long testLong = 6L;
            msg.WriteInt64(testLong);
            msg.Reset();
            Assert.IsTrue((long)msg.ReadObject() == testLong);
            msg.ClearBody();

            float testFloat = 6.6f;
            msg.WriteSingle(testFloat);
            msg.Reset();
            Assert.IsTrue((float)msg.ReadObject() == testFloat);
            msg.ClearBody();

            double testDouble = 7.7d;
            msg.WriteDouble(testDouble);
            msg.Reset();
            Assert.IsTrue((double)msg.ReadObject() == testDouble);
            msg.ClearBody();

            char testChar = 'z';
            msg.WriteChar(testChar);
            msg.Reset();
            Assert.IsTrue((char)msg.ReadObject() == testChar);
            msg.ClearBody();

            byte[] data = new byte[50];
            for(int i = 0; i < data.Length; i++)
            {
                data[i] = (byte)i;
            }
            msg.WriteBytes(data);
            msg.Reset();
            byte[] valid = (byte[])msg.ReadObject();
            Assert.IsTrue(valid.Length == data.Length);
            for(int i = 0; i < valid.Length; i++)
            {
                Assert.IsTrue(valid[i] == data[i]);
            }
            msg.ClearBody();
            msg.WriteBoolean(true);
            msg.Reset();
            Assert.IsTrue((bool)msg.ReadObject());
        }
        public void TestReadLong()
        {
            ActiveMQStreamMessage msg = new ActiveMQStreamMessage();

            long test = 4L;
            msg.WriteInt64(test);
            msg.Reset();
            Assert.IsTrue(msg.ReadInt64() == test);
            msg.Reset();
            Assert.IsTrue(msg.ReadString() == (test).ToString());
            msg.Reset();
            try
            {
                msg.ReadBoolean();
                Assert.Fail("Should have thrown exception");
            }
            catch(MessageFormatException)
            {
            }
            msg.Reset();
            try
            {
                msg.ReadByte();
                Assert.Fail("Should have thrown exception");
            }
            catch(MessageFormatException)
            {
            }
            msg.Reset();
            try
            {
                msg.ReadInt16();
                Assert.Fail("Should have thrown exception");
            }
            catch(MessageFormatException)
            {
            }
            msg.Reset();
            try
            {
                msg.ReadInt32();
                Assert.Fail("Should have thrown exception");
            }
            catch(MessageFormatException)
            {
            }
            msg.Reset();
            try
            {
                msg.ReadSingle();
                Assert.Fail("Should have thrown exception");
            }
            catch(MessageFormatException)
            {
            }
            msg.Reset();
            try
            {
                msg.ReadDouble();
                Assert.Fail("Should have thrown exception");
            }
            catch(MessageFormatException)
            {
            }
            msg.Reset();
            try
            {
                msg.ReadChar();
                Assert.Fail("Should have thrown exception");
            }
            catch(MessageFormatException)
            {
            }
            msg.Reset();
            try
            {
                msg.ReadBytes(new byte[1]);
                Assert.Fail("Should have thrown exception");
            }
            catch(MessageFormatException)
            {
            }
            msg = new ActiveMQStreamMessage();
            msg.WriteObject((Int64) 1);
            // Reset so it's readable now
            msg.Reset();
            Assert.AreEqual( (Int64) 1, msg.ReadObject());
        }