Esempio n. 1
0
        /// <summary>
        /// Creates a new object.
        /// </summary>
        public FlightSimulatorXPresenter()
        {
            Provider          = new DefaultProvider();
            _FlightSimulatorX = Factory.Singleton.Resolve <IFlightSimulatorX>();

            Factory.Singleton.Resolve <IConfigurationStorage>().Singleton.ConfigurationChanged += ConfigurationStorage_ConfigurationChanged;
        }
        /// <summary>
        /// Creates a new object.
        /// </summary>
        public FlightSimulatorXPresenter()
        {
            Provider          = new DefaultProvider();
            _FlightSimulatorX = Factory.Resolve <IFlightSimulatorX>();
            _Clock            = Factory.Resolve <IClock>();

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

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

            if (_Fsx != null)
            {
                _Fsx.Dispose();
            }
            _Fsx = null;
        }
Esempio n. 5
0
        public void TestInitialise()
        {
            _OriginalClassFactory = Factory.CreateChildFactory();

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

            _Fsx = Factory.Resolve <IFlightSimulatorX>();

            _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 <FlightSimulatorXException> >();
            _AircraftInformationReceivedEvent     = new EventRecorder <EventArgs <ReadAircraftInformation> >();
            _SlewToggledEvent = new EventRecorder <EventArgs>();

            _ReadAircraftInformation  = new ReadAircraftInformation();
            _WriteAircraftInformation = new WriteAircraftInformation();
            _Message = new Message();
        }
        public void TestInitialise()
        {
            _OriginalClassFactory = Factory.Singleton.CreateChildFactory();

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

            _Fsx = Factory.Singleton.Resolve<IFlightSimulatorX>();

            _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<FlightSimulatorXException>>();
            _AircraftInformationReceivedEvent = new EventRecorder<EventArgs<ReadAircraftInformation>>();
            _SlewToggledEvent = new EventRecorder<EventArgs>();

            _ReadAircraftInformation = new ReadAircraftInformation();
            _WriteAircraftInformation = new WriteAircraftInformation();
            _Message = new Message();
        }
        /// <summary>
        /// Creates a new object.
        /// </summary>
        public FlightSimulatorXPresenter()
        {
            Provider = new DefaultProvider();
            _FlightSimulatorX = Factory.Singleton.Resolve<IFlightSimulatorX>();

            Factory.Singleton.Resolve<IConfigurationStorage>().Singleton.ConfigurationChanged += ConfigurationStorage_ConfigurationChanged;
        }
        public void TestCleanup()
        {
            Factory.RestoreSnapshot(_OriginalClassFactory);

            if(_Fsx != null) _Fsx.Dispose();
            _Fsx = null;
        }
        public void FlightSimulatorX_Constructor_Initialises_To_Known_State_And_Properties_Work()
        {
            _Fsx.Dispose();
            _Fsx = Factory.Singleton.Resolve<IFlightSimulatorX>();

            Assert.AreEqual(false, _Fsx.Connected);
            Assert.AreEqual(Strings.Disconnected, _Fsx.ConnectionStatus);
            Assert.AreEqual(0, _Fsx.MessagesReceivedCount);
            Assert.AreEqual(false, _Fsx.IsFrozen);
        }