public void TestReadOnlyProperties()
{
ActiveMQMessage msg = new ActiveMQMessage();
String propertyName = "property";
msg.ReadOnlyProperties = true;
try
{
msg.Properties[propertyName] = new Object();
Assert.Fail("Should have thrown exception");
}
catch(MessageNotWriteableException)
{
}
try
{
msg.Properties.SetString(propertyName, "test");
Assert.Fail("Should have thrown exception");
}
catch(MessageNotWriteableException)
{
}
try
{
msg.Properties.SetBool(propertyName, true);
Assert.Fail("Should have thrown exception");
}
catch(MessageNotWriteableException)
{
}
try
{
msg.Properties.SetByte(propertyName, (byte)1);
Assert.Fail("Should have thrown exception");
}
catch(MessageNotWriteableException) {
}
try
{
msg.Properties.SetShort(propertyName, (short)1);
Assert.Fail("Should have thrown exception");
}
catch(MessageNotWriteableException)
{
}
try
{
msg.Properties.SetInt(propertyName, 1);
Assert.Fail("Should have thrown exception");
}
catch(MessageNotWriteableException)
{
}
try
{
msg.Properties.SetLong(propertyName, 1);
Assert.Fail("Should have thrown exception");
}
catch(MessageNotWriteableException)
{
}
try
{
msg.Properties.SetFloat(propertyName, (float)1.5);
Assert.Fail("Should have thrown exception");
}
catch(MessageNotWriteableException)
{
}
try
{
msg.Properties.SetDouble(propertyName, 1.5);
Assert.Fail("Should have thrown exception");
}
catch(MessageNotWriteableException)
{
}
}