private static void CheckInvalidOperation (Message m, String property)
		{
			PropertyInfo pi = m.GetType ().GetProperty (property);
			try {
				Assert.IsNotNull (pi, "Property not defined: " + property);
				object o = pi.GetValue (m, null);
				Assert.Fail (property + ": " + o);
			} catch (InvalidOperationException) {
			} catch (TargetInvocationException e) {
				Assert.AreEqual (typeof (InvalidOperationException), 
				                 e.InnerException.GetType ());
			}
		}
		private static void CheckArgumentInvalid(Message m, String property, Type exceptionType)
		{
			PropertyInfo pi = m.GetType().GetProperty(property);
			try {
				Assert.IsNotNull(pi, "Property not defined: " + property);
				pi.SetValue(m, null, null);
				Assert.Fail(property);
			} catch (InvalidOperationException) {
			} catch (TargetInvocationException e) {
				Assert.AreEqual(exceptionType,
				                e.InnerException.GetType(),
				                property);
			}
		}
Example #3
0
        private static void ProcessContextProperties(Context context, XmlNodeList props, Message msg)
		{
			foreach( XmlNode prop in props )
			{
				// <ContextProperty MSMQProp="CorrelationId" CtxPropName="MSMQ_CorrelationId" />
				string ctxPropName = prop.SelectSingleNode("@CtxPropName").Value;
				string msmqPropName = prop.SelectSingleNode("@MSMQProp").Value;

				PropertyInfo pi = msg.GetType().GetProperty(msmqPropName);
				object val;
				try
				{
					val = pi.GetValue(msg, null);
				}
				catch(Exception)
				{
					context.LogInfo("The property: \"{0}\" did not have a value set", msmqPropName );
					continue;
				}

				context.LogInfo("Property: \"{0}\", Value: \"{1}\" written to context", msmqPropName, val );
				context.Add( ctxPropName, val );
			}
		}