public void Test()
        {
            var processor = MessagesRouterFactory.Create <TestMessagesHandler, TestMessagesDispatcher>();
            var handler   = new TestMessagesHandler();

            handler.TestMessage1Processed.Should().BeFalse();
            handler.TestMessage2Processed.Should().BeFalse();

            var serializer = new BinarySerializer();

            var testMessage1        = new TestMessage1();
            var testMessage2        = new TestMessage2();
            var testFailMessage     = new TestFailMessage();
            var testMessage1Data    = serializer.Serialize(testMessage1);
            var testMessage2Data    = serializer.Serialize(testMessage2);
            var testFailMessageData = serializer.Serialize(testFailMessage);

            processor.Route(serializer, testMessage1.OperationCode, testMessage1Data, 0, testMessage1Data.Length, Guid.Empty,
                            handler).Handled
            .Should().BeTrue();
            handler.TestMessage1Processed.Should().BeTrue();
            handler.TestMessage2Processed.Should().BeFalse();

            processor.Route(serializer, testMessage2.OperationCode, testMessage2Data, 0, testMessage2Data.Length, Guid.Empty,
                            handler).Handled
            .Should().BeTrue();
            handler.TestMessage1Processed.Should().BeTrue();
            handler.TestMessage2Processed.Should().BeTrue();

            handler.TestMessage1Processed.Should().BeTrue();
            handler.TestMessage2Processed.Should().BeTrue();

            processor.Route(serializer, testFailMessage.OperationCode, testFailMessageData, 0, testFailMessageData.Length, Guid.Empty,
                            handler).Handled.Should().BeFalse();
        }
 public bool Handle(TestMessage2 message, Guid sessionId)
 {
     TestMessage2Processed = true;
     return(true);
 }
 public bool Handle(TestMessage2 message, Guid sessionId, TestMessagesHandler ctx)
 {
     return(ctx.Handle(message, sessionId));
 }