Example #1
0
        public void TestMessageParameterizedWithString()
        {
            Object             service    = new TestServiceWithMessageTypes();
            IList <MethodInfo> candidates = HandlerMethodUtils.GetCandidateHandlerMethods(service);
            PayloadTypeMatchingHandlerMethodResolver methodResovler =
                new PayloadTypeMatchingHandlerMethodResolver(candidates);

            Type[]     types    = new[] { typeof(IMessage <string>) };
            MethodInfo expected = typeof(TestServiceWithMessageTypes).GetMethod("StringParameterizedMessage", types);
            IMessage   message  = new Message <String>("foo");
            MethodInfo resolved = methodResovler.ResolveHandlerMethod(message);

            Assert.That(resolved, Is.EqualTo(expected));
            Assert.That(resolved.Invoke(service, new object[] { message }), Is.EqualTo("foo"));
        }
 public void TestStringMessageTypedParameter()
 {
     Object service = new TestServiceWithMessageTypes();
     IList<MethodInfo> candidates = HandlerMethodUtils.GetCandidateHandlerMethods(service);
     PayloadTypeMatchingHandlerMethodResolver methodResovler =
         new PayloadTypeMatchingHandlerMethodResolver(candidates);
     Type[] types = new[] {typeof (StringMessage)};
     MethodInfo expected = typeof (TestServiceWithMessageTypes).GetMethod("StringMessage", types);
     IMessage message = new StringMessage("foo");
     MethodInfo resolved = methodResovler.ResolveHandlerMethod(message);
     Assert.That(resolved, Is.EqualTo(expected));
     Assert.That(resolved.Invoke(service, new object[] {message}), Is.EqualTo("foo"));
 }