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

TestIntPropertyConversion() private method

private TestIntPropertyConversion ( ) : void
return void
        public void TestIntPropertyConversion()
        {
            ActiveMQMessage msg = new ActiveMQMessage();
            String propertyName = "property";
            msg.Properties.SetInt(propertyName, (int)1);

            Assert.AreEqual((int)msg.Properties[propertyName], 1);
            Assert.AreEqual(msg.Properties.GetInt(propertyName), 1);
            Assert.AreEqual(msg.Properties.GetLong(propertyName), 1);
            Assert.AreEqual(msg.Properties.GetString(propertyName), "1");

            try
            {
                msg.Properties.GetBool(propertyName);
                Assert.Fail("Should have thrown exception");
            }
            catch(MessageFormatException)
            {
            }

            try
            {
                msg.Properties.GetByte(propertyName);
                Assert.Fail("Should have thrown exception");
            }
            catch(MessageFormatException)
            {
            }

            try
            {
                msg.Properties.GetShort(propertyName);
                Assert.Fail("Should have thrown exception");
            }
            catch(MessageFormatException)
            {
            }

            try
            {
                msg.Properties.GetFloat(propertyName);
                Assert.Fail("Should have thrown exception");
            }
            catch(MessageFormatException)
            {
            }

            try
            {
                msg.Properties.GetDouble(propertyName);
                Assert.Fail("Should have thrown exception");
            }
            catch(MessageFormatException)
            {
            }
        }