The dialog now carries N1MM's fields in N1MM's order, with the labels to the left of the boxes and the tip text at the top right. New fields in StoredStation: the address, the licence class, the position, the radio, the antenna and the email address. The grid square and the position fill each other in, as they do in N1MM. Which box has focus decides the direction, because TextChanged arrives too late to tell a typed edit from a programmed one. The fields N1MM's form does not have are gone from it. Continent and the country prefix are looked up from the callsign after Ok; the rest keep the value they had. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
58 lines
1.7 KiB
C#
58 lines
1.7 KiB
C#
using Nonemm.Core;
|
|
|
|
namespace Nonemm.Core.Tests;
|
|
|
|
public class GridSquareTests
|
|
{
|
|
[Fact]
|
|
public void FourCharacterSquareCentresOnTheSquare()
|
|
{
|
|
Assert.True(GridSquare.TryParse("JN88", out GridSquare grid));
|
|
Assert.Equal(48.5, grid.Latitude, 3);
|
|
Assert.Equal(17.0, grid.Longitude, 3);
|
|
}
|
|
|
|
[Fact]
|
|
public void SixCharacterSquareIsMorePrecise()
|
|
{
|
|
Assert.True(GridSquare.TryParse("FN31pr", out GridSquare grid));
|
|
Assert.Equal(41.7, grid.Latitude, 1);
|
|
Assert.Equal(-72.7, grid.Longitude, 1);
|
|
}
|
|
|
|
[Theory]
|
|
[InlineData("")]
|
|
[InlineData("JN8")]
|
|
[InlineData("SN89")]
|
|
[InlineData("JNXY")]
|
|
public void MalformedLocatorIsRejected(string text) =>
|
|
Assert.False(GridSquare.TryParse(text, out _));
|
|
|
|
[Fact]
|
|
public void DistanceIsTheGreatCircleBetweenSquareCentres()
|
|
{
|
|
Assert.True(GridSquare.TryParse("JO99", out GridSquare jo99));
|
|
Assert.True(GridSquare.TryParse("IO91", out GridSquare io91));
|
|
Assert.InRange(jo99.DistanceTo(io91), 1525, 1540);
|
|
}
|
|
|
|
[Fact]
|
|
public void BearingIsZeroDueNorth()
|
|
{
|
|
Assert.True(GridSquare.TryParse("JO99", out GridSquare south));
|
|
Assert.True(GridSquare.TryParse("JP90", out GridSquare north));
|
|
Assert.Equal(0, south.BearingTo(north), 6);
|
|
}
|
|
|
|
[Theory]
|
|
[InlineData("JN88md")]
|
|
[InlineData("FN31pr")]
|
|
[InlineData("AA00aa")]
|
|
[InlineData("RR99xx")]
|
|
public void LocatorOfASquareCentreIsThatSquare(string locator)
|
|
{
|
|
Assert.True(GridSquare.TryParse(locator, out GridSquare grid));
|
|
Assert.Equal(locator, GridSquare.From(grid.Latitude, grid.Longitude));
|
|
}
|
|
}
|