using Nonemm.Core; using Nonemm.Core.Country; using Nonemm.Spotting; namespace Nonemm.Session.Tests; public class InfoLinesTests { private static readonly CountryFile Countries = CountryFile.Parse( """ Slovak Republic: 15: 28: EU: 48.67: -19.50: -1.0: OM: OM; United States: 05: 08: NA: 37.60: 91.87: 5.0: K: K,W; """); [Fact] public void TheCountryLineNamesTheContinentAndTheZoneTheContestCounts() { CountryLookup country = Countries.Find("OM3XYZ")!; Assert.Equal("OM: EU/Slovak Republic, Zn 15", InfoLines.Country(country, usesItuZones: false)); Assert.Equal("OM: EU/Slovak Republic, Zn 28", InfoLines.Country(country, usesItuZones: true)); } [Fact] public void ABearingPutsKilometresFirstOutsideNorthAmerica() { StationPath path = new(38, 9156, null, null); Assert.Equal("Hdg 38° LP 218° 9156km 5689mi", InfoLines.Bearing(path, isNorthAmerica: false)); Assert.Equal("Hdg 38° LP 218° 5689mi 9156km", InfoLines.Bearing(path, isNorthAmerica: true)); } [Fact] public void ASunriseWithinTheHourIsSaidSo() { CountryLookup country = Countries.Find("OM3XYZ")!; (DateTime rise, _) = SunTimes.For(country.Latitude, country.Longitude, new DateTime(2026, 8, 28))!.Value; SunLine line = InfoLines.Sun(country, rise.AddMinutes(-20)); Assert.True(line.IsSoon); Assert.Contains("[Sunrise in 20 minutes]", line.Text); } [Fact] public void ASunsetThatHasJustPassedIsSaidSo() { CountryLookup country = Countries.Find("OM3XYZ")!; (_, DateTime set) = SunTimes.For(country.Latitude, country.Longitude, new DateTime(2026, 8, 28))!.Value; SunLine line = InfoLines.Sun(country, set.AddMinutes(10)); Assert.Contains("[Sunset was 10 minutes ago]", line.Text); } [Fact] public void HisTimeIsLeftOutForACountryWithManyTimeZones() { DateTime noon = new(2026, 8, 28, 12, 0, 0, DateTimeKind.Utc); Assert.Contains("His time: 1300(Fri)", InfoLines.Sun(Countries.Find("OM3XYZ")!, noon).Text); Assert.DoesNotContain("His time", InfoLines.Sun(Countries.Find("W1AW")!, noon).Text); } [Fact] public void ASpotShowsHowManyMinutesAgoItWasMade() { DateTime now = new(2026, 8, 28, 12, 10, 30, DateTimeKind.Utc); Spot spot = new( Callsign.Parse("K1ABC"), Frequency.FromKilohertz(14032.3), now.AddMinutes(-3), SpotSource.Cluster, "W8WWV-#", "CW 25 dB"); Assert.Equal("K1ABC - 14032.3 [W8WWV-# @ -3 min] - CW 25 dB", InfoLines.Spot(spot, now)); } }