Frequencies, bands, modes, callsigns, grid squares and the country file live in Nonemm.Core. Nonemm.Contests holds the scoring engine and CQ WW and CQ WPX. Nonemm.Storage writes N1MM's DXLOG schema, and Nonemm.Formats writes Cabrillo 3.0 and reads and writes ADIF. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
71 lines
2.2 KiB
C#
71 lines
2.2 KiB
C#
using Nonemm.Core;
|
|
using Nonemm.Core.Country;
|
|
|
|
namespace Nonemm.Core.Tests.Country;
|
|
|
|
public class CountryFileTests
|
|
{
|
|
private const string Sample = """
|
|
Sicily: 15: 28: EU: 37.50: -14.00: -1.0: *IT9:
|
|
IT9,IW9,ID9;
|
|
Italy: 15: 28: EU: 42.83: -12.83: -1.0: I:
|
|
I,IK,IZ,=IG9ABC;
|
|
United States: 05: 08: NA: 37.60: 91.87: 5.0: K:
|
|
K,W,N,K6(3)[6],=W1AW;
|
|
Fiji: 32: 56: OC: -17.78: -177.92: -12.0: 3D2:
|
|
3D2;
|
|
""";
|
|
|
|
private static readonly CountryFile File = CountryFile.Parse(Sample);
|
|
|
|
[Fact]
|
|
public void LongestPrefixWins() =>
|
|
Assert.Equal("IT9", File.Find("IT9ABC")?.Entity.PrimaryPrefix);
|
|
|
|
[Fact]
|
|
public void ShorterPrefixStillMatches() =>
|
|
Assert.Equal("I", File.Find("IK2XYZ")?.Entity.PrimaryPrefix);
|
|
|
|
[Fact]
|
|
public void WaeOnlyEntitiesAreMarked() =>
|
|
Assert.True(File.Find("IT9ABC")?.Entity.IsWaeOnly);
|
|
|
|
[Fact]
|
|
public void WholeCallEntryBeatsThePrefix() =>
|
|
Assert.Equal("I", File.Find("IG9ABC")?.Entity.PrimaryPrefix);
|
|
|
|
[Fact]
|
|
public void PrefixOverrideChangesTheZone()
|
|
{
|
|
CountryLookup? found = File.Find("K6XYZ");
|
|
Assert.Equal(3, found?.CqZone);
|
|
Assert.Equal(6, found?.ItuZone);
|
|
}
|
|
|
|
[Fact]
|
|
public void PrefixWithoutOverrideKeepsTheEntityZone() =>
|
|
Assert.Equal(5, File.Find("W1XYZ")?.CqZone);
|
|
|
|
[Fact]
|
|
public void PortableStationIsLookedUpByItsPortablePrefix() =>
|
|
Assert.Equal("3D2", File.Find("3D2/K1ABC")?.Entity.PrimaryPrefix);
|
|
|
|
[Fact]
|
|
public void MaritimeMobileBelongsToNoEntity() =>
|
|
Assert.Null(File.Find("K1ABC/MM"));
|
|
|
|
[Fact]
|
|
public void LongitudeComesBackEastPositive() =>
|
|
Assert.Equal(-91.87, File.Find("W1XYZ")!.Longitude, 2);
|
|
|
|
[Fact]
|
|
public void UnknownCallHasNoEntity() =>
|
|
Assert.Null(File.Find("XX9ZZZ"));
|
|
|
|
[Theory]
|
|
[InlineData("")]
|
|
[InlineData("<html>404 not found</html>")]
|
|
public void TextThatIsNotACountryFileIsRejected(string text) =>
|
|
Assert.Throws<FormatException>(() => CountryFile.Parse(text));
|
|
}
|