public void Should_invoke_handle_method() { var cache = new MessageHandlerRegistry(new Conventions()); cache.CacheMethodForHandler(typeof(StubHandler), typeof(StubMessage)); var handler = new StubHandler(); cache.InvokeHandle(handler, new StubMessage()); Assert.IsTrue(handler.HandleCalled); }
public void Should_have_passed_through_correct_message() { var cache = new MessageHandlerRegistry(new Conventions()); cache.CacheMethodForHandler(typeof(StubHandler), typeof(StubMessage)); var handler = new StubHandler(); var stubMessage = new StubMessage(); cache.InvokeHandle(handler, stubMessage); Assert.AreEqual(stubMessage, handler.HandledMessage); }
public void RunNew() { var cache = new MessageHandlerRegistry(new Conventions()); cache.CacheMethodForHandler(typeof(StubMessageHandler), typeof(StubMessage)); cache.CacheMethodForHandler(typeof(StubTimeoutHandler), typeof(StubTimeoutState)); var handler1 = new StubMessageHandler(); var handler2 = new StubTimeoutHandler(); var stubMessage1 = new StubMessage(); var stubMessage2 = new StubTimeoutState(); cache.InvokeHandle(handler1, stubMessage1); cache.InvokeHandle(handler2, stubMessage2); var startNew = Stopwatch.StartNew(); for (var i = 0; i < 100000; i++) { cache.InvokeHandle(handler1, stubMessage1); cache.InvokeHandle(handler2, stubMessage2); } startNew.Stop(); Trace.WriteLine(startNew.ElapsedMilliseconds); }