public void speed_capture_messages_are_translated_into_set_driver_speed_messages(SessionType session)
        {
            In(session).Assert(translator =>
            {
                translator.GetDriver(1).Name = "J. BUTTON";
                translator.GetDriver(2).Name = "M. SCHUMACHER";

                Assert.Null(translator.Translate(new SpeedCaptureMessage(SpeedCaptureLocation.S3, new KeyValuePair<string, int>[0])));

                var expected = new CompositeMessage(
                    new SetDriverSpeedMessage(1, SpeedCaptureLocation.S3, 1),
                    new SetDriverSpeedMessage(2, SpeedCaptureLocation.S3, 2)
                );

                var translated = translator.Translate(new SpeedCaptureMessage(SpeedCaptureLocation.S3, new KeyValuePair<string, int>[]
                {
                    new KeyValuePair<string, int>("BUT", 1),
                    new KeyValuePair<string, int>("MSC", 2)
                }));

                var actual = Assert.IsType<CompositeMessage>(translated);

                Assert.Equal(expected.Messages.Count, actual.Messages.Count);
                for(int i = 0; i < expected.Messages.Count; ++i)
                {
                    Assert.MessagesAreEqual(expected.Messages[i], actual.Messages[i]);
                }
            });
        }
        public void composite_messages_are_expanded_when_written()
        {
            var writer = new ObjectWriterStub();
            var graph = new CompositeMessage(
                EndOfSessionMessage.Instance,
                new CompositeMessage(
                        StartSessionTimeCountdownMessage.Instance,
                        new CompositeMessage(StopSessionTimeCountdownMessage.Instance)));

            writer.WriteMessage(graph);
            Assert.Equal(3, writer.Graphs.Count);
            Assert.Same(EndOfSessionMessage.Instance, writer.Graphs[0]);
            Assert.Same(StartSessionTimeCountdownMessage.Instance, writer.Graphs[1]);
            Assert.Same(StopSessionTimeCountdownMessage.Instance, writer.Graphs[2]);
        }