Inheritance: ModelBase, IMessageProcessor
Example #1
0
        public void changes_to_the_last_message_received_on_property_raise_the_property_changed_event()
        {
            var model = new FeedModel();
            var observer = model.CreateObserver();

            model.Process(new SetStreamValidityMessage(false));
            Assert.True(observer.HasChanged(x => x.LastMessageReceivedOn));
        }
Example #2
0
        public void changes_to_the_message_count_property_raise_the_property_changed_event()
        {
            var model = new FeedModel();
            var observer = model.CreateObserver();

            model.Process(new SetStreamValidityMessage(false));
            Assert.True(observer.HasChanged(x => x.MessageCount));
        }
Example #3
0
        public void changes_to_the_copyright_property_raise_the_property_changed_event()
        {
            var model = new FeedModel();
            var observer = model.CreateObserver();

            model.Process(new SetCopyrightMessage("1"));
            Assert.True(observer.HasChanged(x => x.Copyright));
        }
Example #4
0
        public void changes_to_the_keyframe_property_raise_the_property_changed_event()
        {
            var model = new FeedModel();
            var observer = model.CreateObserver();

            model.Process(new SetKeyframeMessage(1));
            Assert.True(observer.HasChanged(x => x.KeyframeNumber));
        }
Example #5
0
 /// <summary>
 /// Initialises a new instance of the <see cref="SessionModel"/> class.
 /// </summary>
 public SessionModel()
 {
     InnerDrivers = new SortableObservableCollection<DriverModel>((x, y) => { return x.Position.CompareTo(y.Position); });
     Drivers = new ReadOnlyObservableCollection<DriverModel>(InnerDrivers);
     DriversById = new Dictionary<int, DriverModel>(25);
     Feed = new FeedModel();
     Grid = GridModelBase.Create(SessionType.None);
     FastestTimes = new FastestTimesModel(this);
     Messages = new MessageModel();
     OneSecondTimer = new DispatcherTimer(DispatcherPriority.Normal);
     OneSecondTimer.Interval = OneSecond;
     OneSecondTimer.Tick += (s, e) => OnOneSecondElapsed();
     SessionStatus = SessionStatus.Finished;
     SpeedCaptures = new SpeedCapturesModel(this);
     Weather = new WeatherModel();
     Builder = new SessionModelBuilder(this);
 }
Example #6
0
            /// <summary>
            /// Initialises a new instance of the <see cref="FeedModelBuilder"/> class and specifies
            /// the <paramref name="model"/> to build.
            /// </summary>
            /// <param name="model">The model to build.</param>
            /// <exception cref="System.ArgumentNullException">
            /// Thrown when <paramref name="model"/> is <see langword="null"/>.
            /// </exception>
            public FeedModelBuilder(FeedModel model)
            {
                Guard.NotNull(model, "model");

                Model = model;
            }
Example #7
0
        public void changes_to_the_ping_interval_property_raise_the_property_changed_event()
        {
            var model = new FeedModel();
            var observer = model.CreateObserver();

            model.Process(new SetPingIntervalMessage(TimeSpan.FromSeconds(1D)));
            Assert.True(observer.HasChanged(x => x.PingInterval));
        }
Example #8
0
 private void assert_properties_have_default_values(FeedModel model)
 {
     Assert.Null(model.Copyright);
     Assert.Equal(0, model.KeyframeNumber);
     Assert.Equal(0, model.MessageCount);
     Assert.Equal(TimeSpan.Zero, model.PingInterval);
     Assert.Null(model.LastMessageReceivedOn);
     Assert.Null(model.Timestamp);
 }
Example #9
0
        public void can_create()
        {
            var model = new FeedModel();

            assert_properties_have_default_values(model);
        }
Example #10
0
        private static FeedModel CreateModel(params Message[] messagesToProcess)
        {
            var model = new FeedModel();

            foreach(var message in messagesToProcess)
            {
                model.Process(message);
            }

            return model;
        }
Example #11
0
        public void process_throws_when_message_is_null()
        {
            var model = new FeedModel();

            Assert.Throws<ArgumentNullException>(() => model.Process(null));
        }
Example #12
0
        public void processing_a_message_updates_the_message_count_property()
        {
            var model = new FeedModel();

            Assert.Equal(0, model.MessageCount);
            model.Process(new SetStreamValidityMessage(false));
            Assert.Equal(1, model.MessageCount);
            model.Process(new SetStreamValidityMessage(false));
            Assert.Equal(2, model.MessageCount);
        }
Example #13
0
        public void processing_a_message_updates_the_last_message_received_on_property()
        {
            var model = new FeedModel();

            model.Process(new SetStreamValidityMessage(false));
            Assert.InRange(model.LastMessageReceivedOn.Value, SysClock.Now().AddMilliseconds(-5), SysClock.Now());
        }
Example #14
0
        public void changes_to_the_timestamp_property_raise_the_property_changed_event()
        {
            var model = new FeedModel();
            var observer = model.CreateObserver();

            model.Process(new SetStreamTimestampMessage());
            Assert.True(observer.HasChanged(x => x.Timestamp));
        }