public IEnumerable <TestCaseData> TestCases()
        {
            foreach (Type nestedType in typeof(TestHelpers.Rpc).GetNestedTypes())
            {
                var scenarioCalls =
                    GetCalls(nestedType, Channel.CallerToDealer, MessageTypes.Rpc)
                    .Concat(GetCalls(nestedType, Channel.DealerToCaller, MessageTypes.Rpc))
                    .GroupBy(x => x.GetRequestId())
                    .Where(x => x.Key != null);

                var registrations =
                    GetCalls(nestedType, Channel.CalleeToDealer,
                             new WampMessageType[] { WampMessageType.v2Register });

                foreach (var currentCase in scenarioCalls)
                {
                    DealerScenario scenario = new DealerScenario();

                    MockClient <IWampClientProxy <MockRaw> > callee = GetCallee(nestedType, scenario.ClientBuilder, scenario.Handler);
                    MockClient <IWampClientProxy <MockRaw> > caller = GetCaller(nestedType, scenario.ClientBuilder);

                    WampMessage <MockRaw> request =
                        currentCase.FirstOrDefault(x => x.MessageType == WampMessageType.v2Call);

                    WampMessage <MockRaw>[] responses =
                        currentCase.Where(x => x.MessageType != WampMessageType.v2Call)
                        .ToArray();

                    scenario.Call = new DealerCall()
                    {
                        Request   = request,
                        Responses = responses
                    };
                    scenario.Registrations = registrations;
                    scenario.Callee        = callee;
                    scenario.Caller        = caller;

                    TestCaseData testCase = new TestCaseData(scenario);
                    testCase.SetName(string.Format("DealerIntegrationTest.{0}.{1}",
                                                   nestedType.Name,
                                                   request.Arguments[2].Value));

                    yield return(testCase);
                }
            }
        }
        public void DealerTest(DealerScenario scenario)
        {
            foreach (var registration in scenario.Registrations)
            {
                scenario.Handler.HandleMessage(scenario.Callee.Client, registration);
            }

            scenario.Handler.HandleMessage(scenario.Caller.Client, scenario.Call.Request);

            foreach (WampMessage <MockRaw> response in scenario.Call.Responses)
            {
                IEnumerable <WampMessage <MockRaw> > recordedMessages =
                    scenario.Caller.Recorder.RecordedMessages;

                WampMessage <MockRaw> mapped =
                    mMapper.MapRequest(response, recordedMessages, false);

                if (mapped == null)
                {
                    Assert.Fail("An expected response of the form {0} was not found", response);
                }
            }
        }