public void TestInitialise()
        {
            _ClassFactorySnapshot = Factory.TakeSnapshot();

            _FlightSimulatorX = TestUtilities.CreateMockImplementation<IFlightSimulatorX>();
            _FlightSimulatorX.Setup(fsx => fsx.IsInstalled).Returns(true);

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

            _Log = TestUtilities.CreateMockSingleton<ILog>();

            _Presenter = Factory.Singleton.Resolve<IFlightSimulatorXPresenter>();

            _Provider = new Mock<IFlightSimulatorXPresenterProvider>() { DefaultValue = DefaultValue.Mock }.SetupAllProperties();
            _Provider.Setup(p => p.UtcNow).Returns(DateTime.UtcNow);
            _LimitTimedInvokeCallbacks = 1;
            int callbacks = 0;
            _Provider.Setup(p => p.TimedInvokeOnBackgroundThread(It.IsAny<Action>(), It.IsAny<int>())).Callback((Action callback, int milliseconds) => {
                if(callbacks++ < _LimitTimedInvokeCallbacks) callback();
            });
            _Presenter.Provider = _Provider.Object;

            _SelectedAircraft = new Mock<IAircraft>() { DefaultValue = DefaultValue.Mock }.SetupAllProperties().Object;
            _View = new Mock<IFlightSimulatorXView>() { DefaultValue = DefaultValue.Mock }.SetupAllProperties();
            _View.Setup(v => v.CanBeRefreshed).Returns(true);
            _View.Setup(v => v.SelectedRealAircraft).Returns(_SelectedAircraft);

            _BaseStationAircraftList = new Mock<IBaseStationAircraftList>() { DefaultValue = DefaultValue.Mock }.SetupAllProperties();
            _FlightSimulatorAircraftList = new Mock<ISimpleAircraftList>() { DefaultValue = DefaultValue.Mock }.SetupAllProperties();

            long trash1, trash2;

            _RealAircraftList = new List<IAircraft>();
            _BaseStationAircraftList.Setup(b => b.TakeSnapshot(out trash1, out trash2)).Returns(_RealAircraftList);

            _FSXAircraftList = new List<IAircraft>();
            var syncLock = new object();
            _FlightSimulatorAircraftList.Setup(f => f.Aircraft).Returns(_FSXAircraftList);
            _FlightSimulatorAircraftList.Setup(f => f.ListSyncLock).Returns(syncLock);

            _WebServer = new Mock<IWebServer>() { DefaultValue = DefaultValue.Mock }.SetupAllProperties();

            _Presenter.BaseStationAircraftList = _BaseStationAircraftList.Object;
            _Presenter.FlightSimulatorAircraftList = _FlightSimulatorAircraftList.Object;
            _Presenter.WebServer = _WebServer.Object;
        }
예제 #2
0
        /// <summary>
        /// Called once the form has been initialised but before it's on display.
        /// </summary>
        /// <param name="e"></param>
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            if (!DesignMode)
            {
                Localise.Form(this);

                _OnlineHelp = new OnlineHelpHelper(this, OnlineHelpAddress.WinFormsFlightSimulatorXDialog);

                _Presenter = Factory.Resolve <IFlightSimulatorXPresenter>();
                _Presenter.FlightSimulatorAircraftList = _FlightSimulatorAircraftList;
                _Presenter.WebServer = _WebServer;
                _Presenter.Initialise(this);
            }
        }
        /// <summary>
        /// Called once the form has been initialised but before it's on display.
        /// </summary>
        /// <param name="e"></param>
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            if(!DesignMode) {
                Localise.Form(this);

                _OnlineHelp = new OnlineHelpHelper(this, OnlineHelpAddress.WinFormsFlightSimulatorXDialog);

                _Presenter = Factory.Singleton.Resolve<IFlightSimulatorXPresenter>();
                _Presenter.BaseStationAircraftList = _BaseStationAircraftList;
                _Presenter.FlightSimulatorAircraftList = _FlightSimulatorAircraftList;
                _Presenter.WebServer = _WebServer;
                _Presenter.Initialise(this);
            }
        }
        public void FlightSimulatorXPresenter_Constructor_Initialises_To_Known_State_And_Properties_Work()
        {
            _Presenter = Factory.Singleton.Resolve<IFlightSimulatorXPresenter>();

            Assert.IsNotNull(_Presenter.Provider);
            TestUtilities.TestProperty(_Presenter, "Provider", _Presenter.Provider, _Provider.Object);

            TestUtilities.TestProperty(_Presenter, "BaseStationAircraftList", null, _BaseStationAircraftList.Object);
            TestUtilities.TestProperty(_Presenter, "FlightSimulatorAircraftList", null, _FlightSimulatorAircraftList.Object);
        }