Apache.NMS.ActiveMQ.Test.Commands.ActiveMQMessageTest.TestSetObjectProperty C# (CSharp) Method

TestSetObjectProperty() private method

private TestSetObjectProperty ( ) : void
return void
        public void TestSetObjectProperty()
        {
            ActiveMQMessage msg = new ActiveMQMessage();
            string name = "property";

            try
            {
                msg.Properties[name] = "string";
                msg.Properties[name] = (Byte) 1;
                msg.Properties[name] = (Int16) 1;
                msg.Properties[name] = (Int32) 1;
                msg.Properties[name] = (Int64) 1;
                msg.Properties[name] = (Single) 1.1f;
                msg.Properties[name] = (Double) 1.1;
                msg.Properties[name] = (Boolean) true;
                msg.Properties[name] = null;
            }
            catch(MessageFormatException)
            {
                Assert.Fail("should accept object primitives and String");
            }

            try
            {
                msg.Properties[name] = new Object();
                Assert.Fail("should accept only object primitives and String");
            }
            catch(MessageFormatException)
            {
            }

            try
            {
                msg.Properties[name] = new StringBuilder();
                Assert.Fail("should accept only object primitives and String");
            }
            catch(MessageFormatException)
            {
            }
        }