[Test] // INT-506
        public void overriddenMethodExcludedFromCandidateList()
        {
            IList <MethodInfo> candidates = HandlerMethodUtils.GetCandidateHandlerMethods(new TestSubclass());

            Assert.That(candidates.Count, Is.EqualTo(1));
            MethodInfo expected = ReflectionUtils.GetMethod(typeof(TestSubclass), "Test", new[] { typeof(string) });

            Assert.That(candidates[0], Is.EqualTo(expected));
        }
        [Test] // INT-506
        public void overridingMethodResolves()
        {
            IList <MethodInfo> candidates = HandlerMethodUtils.GetCandidateHandlerMethods(new TestSubclass());
            PayloadTypeMatchingHandlerMethodResolver resolver = new PayloadTypeMatchingHandlerMethodResolver(candidates);
            MethodInfo resolved = resolver.ResolveHandlerMethod(new StringMessage("test"));
            MethodInfo expected = ReflectionUtils.GetMethod(typeof(TestSubclass), "Test", new[] { typeof(string) });

            Assert.That(resolved, Is.EqualTo(expected));
        }
Exemplo n.º 3
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 InitResolver()
        {
            IList <MethodInfo> candidates = HandlerMethodUtils.GetCandidateHandlerMethods(new TestService());

            _resolver = new PayloadTypeMatchingHandlerMethodResolver(candidates);
        }