public void BaseStationMessageEventArgs_Constructs_To_Known_State_And_Properties_Work()
 {
     BaseStationMessage message = new Mock<BaseStationMessage>().Object;
     BaseStationMessageEventArgs args = new BaseStationMessageEventArgs(message);
     Assert.AreSame(message, args.Message);
 }
 /// <summary>
 /// Raised when the listener picks up a Port 30003 format message (or derives one from a raw message).
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="args"></param>
 private void Listener_Port30003MessageReceived(object sender, BaseStationMessageEventArgs args)
 {
     if(Online) {
         var bytes = Encoding.ASCII.GetBytes(String.Concat(args.Message.ToBaseStationString(), "\r\n"));
         BroadcastProvider.Send(bytes);
     }
 }
        public void TestInitialise()
        {
            _BackgroundException = null;

            _ClassFactorySnapshot = Factory.TakeSnapshot();

            _RuntimeEnvironment = TestUtilities.CreateMockSingleton<IRuntimeEnvironment>();
            _RuntimeEnvironment.Setup(r => r.IsTest).Returns(true);

            _ConfigurationStorage = TestUtilities.CreateMockSingleton<IConfigurationStorage>();
            _Configuration = new Configuration();
            _ConfigurationStorage.Setup(m => m.Load()).Returns(_Configuration);

            _AircraftPictureManager = TestUtilities.CreateMockSingleton<IAircraftPictureManager>();
            _HeartbeatService = TestUtilities.CreateMockSingleton<IHeartbeatService>();
            _AutoConfigPictureFolderCache = TestUtilities.CreateMockSingleton<IAutoConfigPictureFolderCache>();
            _PictureDirectoryCache = new Mock<IDirectoryCache>() { DefaultValue = DefaultValue.Mock }.SetupAllProperties();
            _AutoConfigPictureFolderCache.Setup(a => a.DirectoryCache).Returns(_PictureDirectoryCache.Object);

            _AircraftList = Factory.Singleton.Resolve<IBaseStationAircraftList>();
            _AircraftList.ExceptionCaught += AircraftListExceptionCaughtHandler;

            _Provider = new Mock<IBaseStationAircraftListProvider>().SetupAllProperties();
            _Provider.Setup(m => m.UtcNow).Returns(DateTime.UtcNow);

            _Port30003Listener = new Mock<IListener>().SetupAllProperties();

            _BaseStationDatabase = new Mock<IBaseStationDatabase>().SetupAllProperties();
            _StandingDataManager = TestUtilities.CreateMockSingleton<IStandingDataManager>();

            _AircraftList.Provider = _Provider.Object;
            _AircraftList.Listener = _Port30003Listener.Object;
            _AircraftList.BaseStationDatabase = _BaseStationDatabase.Object;
            _AircraftList.StandingDataManager = _StandingDataManager.Object;

            _BaseStationMessage = new BaseStationMessage();
            _BaseStationMessage.MessageType = BaseStationMessageType.Transmission;
            _BaseStationMessage.Icao24 = "4008F6";
            _BaseStationMessageEventArgs = new BaseStationMessageEventArgs(_BaseStationMessage);

            _BaseStationAircraft = new BaseStationAircraft();
            _BaseStationDatabase.Setup(m => m.GetAircraftByCode("4008F6")).Returns(_BaseStationAircraft);

            _Heathrow = new Airport() { IcaoCode = "EGLL", IataCode = "LHR", Name = "Heathrow", Country = "UK", };
            _JohnFKennedy = new Airport() { IcaoCode = "KJFK", IataCode = "JFK", Country = "USA", };
            _Helsinki = new Airport() { IataCode = "HEL", };
            _Boston = new Airport() { IcaoCode = "KBOS", };
            _Route = new Route() { From = _Heathrow, To = _JohnFKennedy, Stopovers = { _Helsinki }, };

            _ExceptionCaughtEvent = new EventRecorder<EventArgs<Exception>>();
            _CountChangedEvent = new EventRecorder<EventArgs>();
        }
 /// <summary>
 /// Called when the background queue pops a message off the queue of messages.
 /// </summary>
 /// <param name="args"></param>
 private void MessageQueue_MessageReceived(BaseStationMessageEventArgs args)
 {
     try {
         TrackFlight(args.Message);
     } catch(ThreadAbortException) {
     } catch(Exception ex) {
         Debug.WriteLine(String.Format("BaseStationDatabaseWriter.Plugin.MessageRelay_MessageReceived caught exception {0}", ex.ToString()));
         Factory.Singleton.Resolve<ILog>().Singleton.WriteLine("Database writer plugin caught exception on message processing: {0}", ex.ToString());
         StatusDescription = String.Format(PluginStrings.ExceptionCaught, ex.Message);
         OnStatusChanged(EventArgs.Empty);
     }
 }
 /// <summary>
 /// Called by the listener when a BaseStation message is received.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="args"></param>
 private void MessageListener_MessageReceived(object sender, BaseStationMessageEventArgs args)
 {
     if(_BackgroundThreadMessageQueue != null) _BackgroundThreadMessageQueue.Enqueue(args);
 }
 /// <summary>
 /// Raised by <see cref="IListener"/> when a message is received from BaseStation.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="args"></param>
 private void BaseStationListener_MessageReceived(object sender, BaseStationMessageEventArgs args)
 {
     if(_Started) ProcessMessage(args.Message);
 }
 /// <summary>
 /// Raises <see cref="Port30003MessageReceived"/>
 /// </summary>
 /// <param name="args"></param>
 private void OnPort30003MessageReceived(BaseStationMessageEventArgs args)
 {
     if(Port30003MessageReceived != null) Port30003MessageReceived(this, args);
 }