Ejemplo n.º 1
0
 public MainViewModel(IFlightSimulator fs)
 {
     this.simulator             = fs;
     simulator.PropertyChanged += delegate(Object sender, PropertyChangedEventArgs e)
     {
         NotifyPropertyChanged("VM" + e.PropertyName);
     };
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Creates a new object.
        /// </summary>
        public FlightSimulatorPresenter()
        {
            Provider          = new DefaultProvider();
            _FlightSimulatorX = Factory.Resolve <IFlightSimulator>();
            _Clock            = Factory.Resolve <IClock>();

            Factory.ResolveSingleton <IConfigurationStorage>().ConfigurationChanged += ConfigurationStorage_ConfigurationChanged;
            Factory.ResolveSingleton <IFeedManager>().FeedsChanged += FeedManager_FeedsChanged;
        }
Ejemplo n.º 3
0
        public void FlightSimulatorX_Constructor_Initialises_To_Known_State_And_Properties_Work()
        {
            _Fsx.Dispose();
            _Fsx = Factory.Resolve <IFlightSimulator>();

            Assert.AreEqual(false, _Fsx.Connected);
            Assert.AreEqual(Strings.Disconnected, _Fsx.ConnectionStatus);
            Assert.AreEqual(0, _Fsx.MessagesReceivedCount);
            Assert.AreEqual(false, _Fsx.IsFrozen);
        }
Ejemplo n.º 4
0
        public void TestCleanup()
        {
            Factory.RestoreSnapshot(_OriginalClassFactory);

            if (_Fsx != null)
            {
                _Fsx.Dispose();
            }
            _Fsx = null;
        }
Ejemplo n.º 5
0
        private void Application_Startup(object sender, StartupEventArgs e)
        {
            MyTelnetClient client = new MyTelnetClient();

            fs = new MyFlightSimulator(client);
            MainWindow wnd = new MainWindow();

            VM = new MainViewModel(fs);
            wnd.DataContext                = VM;
            wnd.dash.DataContext           = new DashboardViewModel(fs);
            wnd.map.DataContext            = new MapViewModel(fs);
            wnd.controllers.DataContext    = new MyControlsViewModel(fs);
            wnd.connect_button.DataContext = new ConnectionViewModel(fs);
            wnd.Show();
        }
Ejemplo n.º 6
0
        public void TestInitialise()
        {
            _OriginalClassFactory = Factory.CreateChildFactory();

            _SimConnect = TestUtilities.CreateMockImplementation <ISimConnectWrapper>();
            _SimConnect.Setup(m => m.IsInstalled).Returns(true);

            _Fsx = Factory.Resolve <IFlightSimulator>();

            _ClientEventIdMap = new Dictionary <string, Enum>();
            _SimConnect.Setup(m => m.MapClientEventToSimEvent(It.IsAny <Enum>(), It.IsAny <string>())).Callback((Enum id, string name) => { _ClientEventIdMap.Add(name, id); });

            _SystemEventIdMap = new Dictionary <string, Enum>();
            _SimConnect.Setup(m => m.SubscribeToSystemEvent(It.IsAny <Enum>(), It.IsAny <string>())).Callback((Enum id, string name) => { _SystemEventIdMap.Add(name, id); });

            _NotificationGroupMap = new Dictionary <Enum, Enum>();
            _SimConnect.Setup(m => m.AddClientEventToNotificationGroup(It.IsAny <Enum>(), It.IsAny <Enum>(), false)).Callback((Enum groupId, Enum eventId, bool maskable) => { _NotificationGroupMap.Add(eventId, groupId); });

            _ReadAircraftInformationDefinitionId = default(Enum);
            _SimConnect.Setup(m => m.RegisterDataDefineStruct <ReadAircraftInformation>(It.IsAny <Enum>())).Callback((Enum definitionId) => { _ReadAircraftInformationDefinitionId = definitionId; });

            _AircraftInformationRequestId = default(Enum);
            _SimConnect.Setup(m => m.RequestDataOnSimObjectType(It.IsAny <Enum>(), It.IsAny <Enum>(), It.IsAny <uint>(), It.IsAny <int>())).Callback((Enum requestId, Enum definitionId, uint radius, int objectType) => {
                if (definitionId == _ReadAircraftInformationDefinitionId)
                {
                    _AircraftInformationRequestId = requestId;
                }
            });

            _WriteAircraftInformationDefinitionId = default(Enum);
            _SimConnect.Setup(m => m.RegisterDataDefineStruct <WriteAircraftInformation>(It.IsAny <Enum>())).Callback((Enum definitionId) => { _WriteAircraftInformationDefinitionId = definitionId; });

            _ConnectionStatusChangedEvent         = new EventRecorder <EventArgs>();
            _FreezeStatusChangedEvent             = new EventRecorder <EventArgs>();
            _SlewStatusChangedEvent               = new EventRecorder <EventArgs>();
            _FlightSimulatorXExceptionRaisedEvent = new EventRecorder <EventArgs <FlightSimulatorException> >();
            _AircraftInformationReceivedEvent     = new EventRecorder <EventArgs <ReadAircraftInformation> >();
            _SlewToggledEvent = new EventRecorder <EventArgs>();

            _ReadAircraftInformation  = new ReadAircraftInformation();
            _WriteAircraftInformation = new WriteAircraftInformation();
            _Message = new Message();
        }