示例#1
0
        public void TestInitialise()
        {
            _OriginalClassFactory = Factory.TakeSnapshot();

            // Note that the class factory will keep returning the SAME instance for all of the
            // interfaces for which CreateMockImplementation is called... this means we can't
            // comprehensively test the handling of multiple servers. Creating a wrapper using
            // Mock<> is kind of possible but gets tricky around events, and in any case it's
            // rather defeating the point of using a mocking framework.
            _Server            = TestUtilities.CreateMockImplementation <IRebroadcastServer>();
            _Listener          = TestUtilities.CreateMockImplementation <IListener>();
            _BroadcastProvider = TestUtilities.CreateMockImplementation <IBroadcastProvider>();

            _ConfigurationStorage = TestUtilities.CreateMockSingleton <IConfigurationStorage>();
            _Configuration        = new Configuration();
            _ConfigurationStorage.Setup(r => r.Load()).Returns(_Configuration);
            _RebroadcastSettings = new RebroadcastSettings()
            {
                Name = "A", Enabled = true, Port = 1000, Format = RebroadcastFormat.Passthrough
            };
            _Configuration.RebroadcastSettings.Add(_RebroadcastSettings);

            _Manager          = Factory.Singleton.Resolve <IRebroadcastServerManager>();
            _Manager.Listener = _Listener.Object;
        }
示例#2
0
        /// <summary>
        /// See interface docs.
        /// </summary>
        /// <param name="view"></param>
        public void Initialise(IMainView view)
        {
            if (view == null)
            {
                throw new ArgumentNullException("view");
            }
            View                    = view;
            View.LogFileName        = Factory.ResolveSingleton <ILog>().FileName;
            View.InvalidPluginCount = Factory.ResolveSingleton <IPluginManager>().IgnoredPlugins.Count;

            var heartbeatService = Factory.ResolveSingleton <IHeartbeatService>();

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

            var newVersionChecker = Factory.ResolveSingleton <INewVersionChecker>();

            newVersionChecker.NewVersionAvailable += NewVersionChecker_NewVersionAvailable;

            _FeedManager = Factory.ResolveSingleton <IFeedManager>();
            _FeedManager.ConnectionStateChanged += FeedManager_ConnectionStateChanged;
            _FeedManager.FeedsChanged           += FeedManager_FeedsChanged;
            UpdateFeedCounters();
            View.ShowFeeds(GetFeedCounters());

            _WebServer = Factory.ResolveSingleton <IAutoConfigWebServer>().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;

            _RebroadcastServerManager = Factory.ResolveSingleton <IRebroadcastServerManager>();
            DoDisplayRebroadcastServerConnections();

            _SharedConfiguration.ConfigurationChanged += SharedConfiguration_ConfigurationChanged;

            DisplayConfigurationSettings();

            View.CheckForNewVersion += View_CheckForNewVersion;
            View.ReconnectFeed      += View_ReconnectFeed;
            View.ResetPolarPlot     += View_ResetPolarPlot;
            View.ToggleServerStatus += View_ToggleServerStatus;
            View.ToggleUPnpStatus   += View_ToggleUPnpStatus;
        }
        public void TestInitialise()
        {
            _OriginalClassFactory = Factory.TakeSnapshot();

            _Server = TestUtilities.CreateMockImplementation <IRebroadcastServer>();

            _Connector = new MockConnector <INetworkConnector, INetworkConnection>();
            Factory.Singleton.RegisterInstance <INetworkConnector>(_Connector.Object);
            _Connector.Object.Authentication = null;

            _PassphraseAuthentication = TestUtilities.CreateMockImplementation <IPassphraseAuthentication>();

            _Feeds     = new List <Mock <IFeed> >();
            _Listeners = new List <Mock <IListener> >();
            var useVisibleFeeds = false;

            _FeedManager = FeedHelper.CreateMockFeedManager(_Feeds, _Listeners, useVisibleFeeds, 1, 2);

            _ConfigurationStorage = TestUtilities.CreateMockSingleton <IConfigurationStorage>();
            _Configuration        = new Configuration();
            _ConfigurationStorage.Setup(r => r.Load()).Returns(_Configuration);
            _RebroadcastSettings = new RebroadcastSettings()
            {
                UniqueId     = 22,
                Name         = "A",
                Enabled      = true,
                Port         = 1000,
                Format       = RebroadcastFormat.Passthrough,
                ReceiverId   = 1,
                StaleSeconds = 3,
                Access       =
                {
                    DefaultAccess = DefaultAccess.Allow,
                },
                IsTransmitter            = false,
                SendIntervalMilliseconds = 1000,
            };
            _Configuration.RebroadcastSettings.Add(_RebroadcastSettings);

            _Manager = Factory.Singleton.Resolve <IRebroadcastServerManager>();
        }
        public void TestInitialise()
        {
            _OriginalClassFactory = Factory.TakeSnapshot();

            // Note that the class factory will keep returning the SAME instance for all of the
            // interfaces for which CreateMockImplementation is called... this means we can't
            // comprehensively test the handling of multiple servers. Creating a wrapper using
            // Mock<> is kind of possible but gets tricky around events, and in any case it's
            // rather defeating the point of using a mocking framework.
            _Server = TestUtilities.CreateMockImplementation<IRebroadcastServer>();
            _Listener = TestUtilities.CreateMockImplementation<IListener>();
            _BroadcastProvider = TestUtilities.CreateMockImplementation<IBroadcastProvider>();

            _ConfigurationStorage = TestUtilities.CreateMockSingleton<IConfigurationStorage>();
            _Configuration = new Configuration();
            _ConfigurationStorage.Setup(r => r.Load()).Returns(_Configuration);
            _RebroadcastSettings = new RebroadcastSettings() { Name = "A", Enabled = true, Port = 1000, Format = RebroadcastFormat.Passthrough };
            _Configuration.RebroadcastSettings.Add(_RebroadcastSettings);

            _Manager = Factory.Singleton.Resolve<IRebroadcastServerManager>();
            _Manager.Listener = _Listener.Object;
        }