Apache.NMS.Test.BytesMessageTest.AssertMessageIsReadOnly C# (CSharp) Method

AssertMessageIsReadOnly() protected method

protected AssertMessageIsReadOnly ( IMessage message ) : void
message IMessage
return void
        protected void AssertMessageIsReadOnly(IMessage message)
        {
            Type writeableExceptionType = typeof(MessageNotWriteableException);
            IBytesMessage theMessage = message as IBytesMessage;
            Assert.IsNotNull(theMessage);
            Assert.Throws(writeableExceptionType, delegate () { theMessage.WriteBoolean(true); });
            Assert.Throws(writeableExceptionType, delegate () { theMessage.WriteByte((byte) 1); });
            Assert.Throws(writeableExceptionType, delegate () { theMessage.WriteBytes(new byte[1]); });
            Assert.Throws(writeableExceptionType, delegate () { theMessage.WriteBytes(new byte[3], 0, 2); });
            Assert.Throws(writeableExceptionType, delegate () { theMessage.WriteChar('a'); });
            Assert.Throws(writeableExceptionType, delegate () { theMessage.WriteDouble(1.5); });
            Assert.Throws(writeableExceptionType, delegate () { theMessage.WriteSingle((float) 1.5); });
            Assert.Throws(writeableExceptionType, delegate () { theMessage.WriteInt32(1); });
            Assert.Throws(writeableExceptionType, delegate () { theMessage.WriteInt64(1); });
            Assert.Throws(writeableExceptionType, delegate () { theMessage.WriteObject("stringobj"); });
            Assert.Throws(writeableExceptionType, delegate () { theMessage.WriteInt16((short) 1); });
            Assert.Throws(writeableExceptionType, delegate () { theMessage.WriteString("utfstring"); });
        }