예제 #1
0
        public void AirnavXRangeMessageConverter_Altitudes_Are_Always_Pressure()
        {
            var aircraft = new AirnavXRangeAircraftJson()
            {
                Icao24   = "A",
                Altitude = 10,
            };

            _Json.Aircraft.Add(aircraft);

            var eventArgs = _Converter.ConvertIntoBaseStationMessageEventArgs(_Json).Single();

            Assert.IsFalse(eventArgs.Message.Supplementary?.AltitudeIsGeometric.GetValueOrDefault() ?? false);
        }
예제 #2
0
        public void AirnavXRangeMessageConverter_Clears_IsTisb()
        {
            // Same story for TISB, the examples have an array called tisb but they're all empty. For now I'll just clear
            // the flag.
            var aircraft = new AirnavXRangeAircraftJson()
            {
                Icao24    = "A",
                Latitude  = 1,
                Longitude = 2,
            };

            _Json.Aircraft.Add(aircraft);

            var eventArgs = _Converter.ConvertIntoBaseStationMessageEventArgs(_Json).Single();

            Assert.IsFalse(eventArgs.Message.IsTisb);
        }
예제 #3
0
        public void AirnavXRangeMessageConverter_Clears_IsMlat()
        {
            // I think MLAT is present on the feed but I don't know what's sent... the examples I have at the moment
            // just show an empty array called mlat. For now I'll just clear the flag for all messages.
            var aircraft = new AirnavXRangeAircraftJson()
            {
                Icao24    = "A",
                Latitude  = 1,
                Longitude = 2,
            };

            _Json.Aircraft.Add(aircraft);

            var eventArgs = _Converter.ConvertIntoBaseStationMessageEventArgs(_Json).Single();

            Assert.IsFalse(eventArgs.Message.IsMlat);
        }
예제 #4
0
 public void TestInitialise()
 {
     _Json = new AirnavXRangeAircraftJson();
 }
예제 #5
0
        public void AirnavXRangeMessageConverter_Copies_Json_Properties_To_Correct_Message_Property()
        {
            var worksheet = new ExcelWorksheetData(TestContext);

            var jsonPropertyName          = worksheet.String("JsonProperty");
            var jsonValueText             = worksheet.EString("JsonValue");
            var messagePropertyName       = worksheet.String("MsgProperty");
            var messageValueText          = worksheet.EString("MsgValue");
            var supplementaryPropertyName = worksheet.String("SuppProperty");
            var supplementaryValueText    = worksheet.EString("SuppValue");

            var isSupplementary = supplementaryPropertyName != null;

            var jsonProperty = typeof(AirnavXRangeAircraftJson).GetProperty(jsonPropertyName);

            if (jsonProperty == null)
            {
                Assert.Fail(jsonPropertyName);
            }
            var jsonValue = TestUtilities.ChangeType(jsonValueText, jsonProperty.PropertyType, CultureInfo.InvariantCulture);

            var messageProperty = isSupplementary ? null : typeof(BaseStationMessage).GetProperty(messagePropertyName);

            if (messageProperty == null && !isSupplementary)
            {
                Assert.Fail(messagePropertyName);
            }
            var messageValue = messageProperty == null ? null : TestUtilities.ChangeType(messageValueText, messageProperty.PropertyType, CultureInfo.InvariantCulture);

            var supplementaryProperty = isSupplementary ? typeof(BaseStationSupplementaryMessage).GetProperty(supplementaryPropertyName) : null;

            if (supplementaryProperty == null && isSupplementary)
            {
                Assert.Fail(supplementaryPropertyName);
            }
            var supplementaryValue = supplementaryProperty == null ? null : TestUtilities.ChangeType(supplementaryValueText, supplementaryProperty.PropertyType, CultureInfo.InvariantCulture);

            var aircraftJson = new AirnavXRangeAircraftJson();

            _Json.Aircraft.Add(aircraftJson);
            jsonProperty.SetValue(aircraftJson, jsonValue, null);

            var eventArgs     = _Converter.ConvertIntoBaseStationMessageEventArgs(_Json).Single();
            var supplementary = eventArgs.Message.Supplementary;

            if (messageProperty != null)
            {
                var actualValue = messageProperty.GetValue(eventArgs.Message, null);
                Assert.AreEqual(messageValue, actualValue, jsonPropertyName);
            }
            else
            {
                if (supplementary == null)
                {
                    if (supplementaryValue != null)
                    {
                        Assert.Fail(jsonPropertyName);
                    }
                }
                else
                {
                    var actualValue = supplementaryProperty.GetValue(supplementary, null);
                    Assert.AreEqual(supplementaryValue, actualValue, jsonPropertyName);
                }
            }
        }