Esempio n. 1
0
        private bool PollAircraftInfoUpdates()
        {
            _planeInfo = _aircraftManager.Get();
            // The Update event handlers will do the logging.

            return(false);
        }
        public void GetAircraftData()
        {
            // Arrange
            AutoResetEvent resetEvent = new AutoResetEvent(false);
            int            errorCount = 0;

            FsConnect fsConnect = new FsConnect();

            fsConnect.ConnectionChanged += (sender, b) =>
            {
                if (b)
                {
                    resetEvent.Set();
                }
            };
            fsConnect.FsError += (sender, args) =>
            {
                errorCount++;
                Console.WriteLine($"Error: {args.ExceptionDescription}");
            };

            fsConnect.Connect("AircraftManagersIntegrationTests", 0);

            bool res = resetEvent.WaitOne(2000);

            if (!res)
            {
                Assert.Fail("Not connected to MSFS within timeout");
            }

            var defId = fsConnect.RegisterDataDefinition <AircraftInfo>();

            AircraftManager <AircraftInfo> aircraftManager = new AircraftManager <AircraftInfo>(fsConnect, defId);

            // Act
            var info = aircraftManager.Get();

            // Assert
            Assert.That(errorCount, Is.Zero);
            Assert.That(info.Title, Is.Not.Empty);
            Assert.That(info.Latitude, Is.Not.EqualTo(0));
            Assert.That(info.Longitude, Is.Not.EqualTo(0));
        }