Exemplo n.º 1
0
        public void TestInitialise()
        {
            _OriginalClassFactory = Factory.TakeSnapshot();

            _ConfigurationStorage = TestUtilities.CreateMockSingleton <IConfigurationStorage>();
            _Configuration        = new Configuration();
            _Configuration.ReceiverLocations.AddRange(_DefaultReceiverLocations);
            _ConfigurationStorage.Setup(r => r.Load()).Returns(_Configuration);

            _Statistics = TestUtilities.CreateMockSingleton <IStatistics>();

            _Listener = TestUtilities.CreateMockImplementation <IListener>();
            _Listener.Setup(r => r.Provider).Returns((IListenerProvider)null);
            _Listener.Setup(r => r.BytesExtractor).Returns((IMessageBytesExtractor)null);
            _Listener.Setup(r => r.RawMessageTranslator).Returns((IRawMessageTranslator)null);
            _Listener.Setup(r => r.ChangeSource(It.IsAny <IListenerProvider>(), It.IsAny <IMessageBytesExtractor>(), It.IsAny <IRawMessageTranslator>(), It.IsAny <bool>()))
            .Callback((IListenerProvider provider, IMessageBytesExtractor extractor, IRawMessageTranslator translator, bool reconnect) => {
                _Listener.Setup(r => r.Provider).Returns(provider);
                _Listener.Setup(r => r.BytesExtractor).Returns(extractor);
                _Listener.Setup(r => r.RawMessageTranslator).Returns(translator);
            });

            CreateNewListenerChildObjectInstances();

            _AutoConfigListener = Factory.Singleton.Resolve <IAutoConfigListener>();
        }
        /// <summary>
        /// See interface docs.
        /// </summary>
        /// <param name="view"></param>
        public void Initialise(IMainView view)
        {
            if (view == null)
            {
                throw new ArgumentNullException("view");
            }
            View = view;
            View.CheckForNewVersion            += View_CheckForNewVersion;
            View.ReconnectToBaseStationClicked += View_ReconnectToBaseStationClicked;
            View.ToggleServerStatus            += View_ToggleServerStatus;
            View.ToggleUPnpStatus  += View_ToggleUPnpStatus;
            View.LogFileName        = Factory.Singleton.Resolve <ILog>().Singleton.FileName;
            View.InvalidPluginCount = Factory.Singleton.Resolve <IPluginManager>().Singleton.IgnoredPlugins.Count;
            if (_BaseStationAircraftList != null)
            {
                View.AircraftCount = _BaseStationAircraftList.Count;
            }

            var heartbeatService = Factory.Singleton.Resolve <IHeartbeatService>().Singleton;

            heartbeatService.SlowTick += HeartbeatService_SlowTick;
            heartbeatService.FastTick += HeartbeatService_FastTick;

            var newVersionChecker = Factory.Singleton.Resolve <INewVersionChecker>().Singleton;

            newVersionChecker.NewVersionAvailable += NewVersionChecker_NewVersionAvailable;

            _AutoConfigListener = Factory.Singleton.Resolve <IAutoConfigListener>().Singleton;
            _AutoConfigListener.Listener.ConnectionStateChanged += BaseStationListener_ConnectionStateChanged;
            View.BaseStationTotalMessages    = _AutoConfigListener.Listener.TotalMessages;
            View.BaseStationConnectionStatus = _AutoConfigListener.Listener.ConnectionStatus;
            View.BaseStationTotalBadMessages = _AutoConfigListener.Listener.TotalBadMessages;

            _WebServer = Factory.Singleton.Resolve <IAutoConfigWebServer>().Singleton.WebServer;
            _WebServer.ExternalAddressChanged += WebServer_ExternalAddressChanged;
            _WebServer.OnlineChanged          += WebServer_OnlineChanged;
            _WebServer.ResponseSent           += WebServer_ResponseSent;
            View.WebServerIsOnline             = _WebServer.Online;
            View.WebServerLocalAddress         = _WebServer.LocalAddress;
            View.WebServerNetworkAddress       = _WebServer.NetworkAddress;
            View.WebServerExternalAddress      = _WebServer.ExternalAddress;

            var pluginManager = Factory.Singleton.Resolve <IPluginManager>().Singleton;

            foreach (var plugin in pluginManager.LoadedPlugins)
            {
                plugin.GuiThreadStartup();
            }

            var rebroadcastServerManager = Factory.Singleton.Resolve <IRebroadcastServerManager>().Singleton;

            rebroadcastServerManager.BroadcastSent      += RebroadcastServerManager_BroadcastSent;
            rebroadcastServerManager.ClientConnected    += RebroadcastServerManager_ClientConnected;
            rebroadcastServerManager.ClientDisconnected += RebroadcastServerManager_ClientDisconnected;

            var configurationStorage = DisplayConfigurationSettings();

            configurationStorage.ConfigurationChanged += ConfigurationStorage_ConfigurationChanged;
        }
        public void TestInitialise()
        {
            _OriginalClassFactory = Factory.TakeSnapshot();

            _ConfigurationStorage = TestUtilities.CreateMockSingleton<IConfigurationStorage>();
            _Configuration = new Configuration();
            _Configuration.ReceiverLocations.AddRange(_DefaultReceiverLocations);
            _ConfigurationStorage.Setup(r => r.Load()).Returns(_Configuration);

            _Statistics = TestUtilities.CreateMockSingleton<IStatistics>();

            _Listener = TestUtilities.CreateMockImplementation<IListener>();
            _Listener.Setup(r => r.Provider).Returns((IListenerProvider)null);
            _Listener.Setup(r => r.BytesExtractor).Returns((IMessageBytesExtractor)null);
            _Listener.Setup(r => r.RawMessageTranslator).Returns((IRawMessageTranslator)null);
            _Listener.Setup(r => r.ChangeSource(It.IsAny<IListenerProvider>(), It.IsAny<IMessageBytesExtractor>(), It.IsAny<IRawMessageTranslator>(), It.IsAny<bool>()))
                     .Callback((IListenerProvider provider, IMessageBytesExtractor extractor, IRawMessageTranslator translator, bool reconnect) => {
                _Listener.Setup(r => r.Provider).Returns(provider);
                _Listener.Setup(r => r.BytesExtractor).Returns(extractor);
                _Listener.Setup(r => r.RawMessageTranslator).Returns(translator);
            });

            CreateNewListenerChildObjectInstances();

            _AutoConfigListener = Factory.Singleton.Resolve<IAutoConfigListener>();
        }
        /// <summary>
        /// See interface docs.
        /// </summary>
        /// <param name="view"></param>
        public void Initialise(IMainView view)
        {
            if(view == null) throw new ArgumentNullException("view");
            View = view;
            View.CheckForNewVersion += View_CheckForNewVersion;
            View.ReconnectToBaseStationClicked += View_ReconnectToBaseStationClicked;
            View.ToggleServerStatus += View_ToggleServerStatus;
            View.ToggleUPnpStatus += View_ToggleUPnpStatus;
            View.LogFileName = Factory.Singleton.Resolve<ILog>().Singleton.FileName;
            View.InvalidPluginCount = Factory.Singleton.Resolve<IPluginManager>().Singleton.IgnoredPlugins.Count;
            if(_BaseStationAircraftList != null) View.AircraftCount = _BaseStationAircraftList.Count;

            var heartbeatService = Factory.Singleton.Resolve<IHeartbeatService>().Singleton;
            heartbeatService.SlowTick += HeartbeatService_SlowTick;
            heartbeatService.FastTick += HeartbeatService_FastTick;

            var newVersionChecker = Factory.Singleton.Resolve<INewVersionChecker>().Singleton;
            newVersionChecker.NewVersionAvailable += NewVersionChecker_NewVersionAvailable;

            _AutoConfigListener = Factory.Singleton.Resolve<IAutoConfigListener>().Singleton;
            _AutoConfigListener.Listener.ConnectionStateChanged += BaseStationListener_ConnectionStateChanged;
            View.BaseStationTotalMessages = _AutoConfigListener.Listener.TotalMessages;
            View.BaseStationConnectionStatus = _AutoConfigListener.Listener.ConnectionStatus;
            View.BaseStationTotalBadMessages = _AutoConfigListener.Listener.TotalBadMessages;

            _WebServer = Factory.Singleton.Resolve<IAutoConfigWebServer>().Singleton.WebServer;
            _WebServer.ExternalAddressChanged += WebServer_ExternalAddressChanged;
            _WebServer.OnlineChanged += WebServer_OnlineChanged;
            _WebServer.ResponseSent += WebServer_ResponseSent;
            View.WebServerIsOnline = _WebServer.Online;
            View.WebServerLocalAddress = _WebServer.LocalAddress;
            View.WebServerNetworkAddress = _WebServer.NetworkAddress;
            View.WebServerExternalAddress = _WebServer.ExternalAddress;

            var pluginManager = Factory.Singleton.Resolve<IPluginManager>().Singleton;
            foreach(var plugin in pluginManager.LoadedPlugins) {
                plugin.GuiThreadStartup();
            }

            var rebroadcastServerManager = Factory.Singleton.Resolve<IRebroadcastServerManager>().Singleton;
            rebroadcastServerManager.BroadcastSent += RebroadcastServerManager_BroadcastSent;
            rebroadcastServerManager.ClientConnected += RebroadcastServerManager_ClientConnected;
            rebroadcastServerManager.ClientDisconnected += RebroadcastServerManager_ClientDisconnected;

            var configurationStorage = DisplayConfigurationSettings();
            configurationStorage.ConfigurationChanged += ConfigurationStorage_ConfigurationChanged;
        }