A spot an operator put on a bandmap, here or on another computer, is drawn in bold. Its hover text names the computer instead of the spotter's callsign. A spot from another computer carries the name from the ADDSPOT message. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
76 lines
2.3 KiB
C#
76 lines
2.3 KiB
C#
using Nonemm.Core;
|
|
|
|
namespace Nonemm.Spotting.Tests;
|
|
|
|
public class SpotDescriptionTests
|
|
{
|
|
private static readonly DateTime At = new(2026, 5, 30, 12, 1, 0, DateTimeKind.Utc);
|
|
private static readonly DateTime Now = At.AddMinutes(41);
|
|
|
|
[Fact]
|
|
public void ASpotNamesTheSpotterTheTimeAndTheComment()
|
|
{
|
|
Spot spot = new(
|
|
Callsign.Parse("JA1XYZ"), Frequency.FromKilohertz(14_025), At, SpotSource.Cluster,
|
|
"K1TTT", "CW 26 dB");
|
|
|
|
Assert.Equal("14025.0 by K1TTT, 41m ago\nCW 26 dB", SpotDescription.Of(spot, Now));
|
|
}
|
|
|
|
[Fact]
|
|
public void ASpotWithoutACommentOrSpotterHasOneLine()
|
|
{
|
|
Spot spot = new(
|
|
Callsign.Parse("JA1XYZ"), Frequency.FromKilohertz(14_025), At, SpotSource.Log);
|
|
|
|
Assert.Equal("14025.0, 41m ago", SpotDescription.Of(spot, Now));
|
|
}
|
|
|
|
[Theory]
|
|
[InlineData("USB")]
|
|
[InlineData("lsb")]
|
|
[InlineData("SSB\a\a")]
|
|
public void ASidebandAloneIsLeftOut(string comment)
|
|
{
|
|
Spot spot = new(
|
|
Callsign.Parse("JA1XYZ"), Frequency.FromKilohertz(14_025), At, SpotSource.Cluster,
|
|
"K1TTT", comment);
|
|
|
|
Assert.Equal("14025.0 by K1TTT, 41m ago", SpotDescription.Of(spot, Now));
|
|
}
|
|
|
|
[Fact]
|
|
public void ControlCharactersAreDroppedFromTheComment()
|
|
{
|
|
Spot spot = new(
|
|
Callsign.Parse("JA1XYZ"), Frequency.FromKilohertz(14_025), At, SpotSource.Cluster,
|
|
"K1TTT", "CW 26 dB\r\a");
|
|
|
|
Assert.Equal("14025.0 by K1TTT, 41m ago\nCW 26 dB", SpotDescription.Of(spot, Now));
|
|
}
|
|
|
|
[Theory]
|
|
[InlineData(20, "14025.0, 0m ago")]
|
|
[InlineData(3600 + 300, "14025.0, 1h 5m ago")]
|
|
public void TheAgeIsInMinutesThenHours(int seconds, string expected)
|
|
{
|
|
Spot spot = new(
|
|
Callsign.Parse("JA1XYZ"), Frequency.FromKilohertz(14_025), At, SpotSource.Log);
|
|
|
|
Assert.Equal(expected, SpotDescription.Of(spot, At.AddSeconds(seconds)));
|
|
}
|
|
|
|
[Fact]
|
|
public void ALocalSpotNamesTheComputerInsteadOfTheSpotter()
|
|
{
|
|
Spot spot = new(
|
|
Callsign.Parse("JA1XYZ"), Frequency.FromKilohertz(14_025), At, SpotSource.Operator,
|
|
"OK1ABC")
|
|
{
|
|
Computer = "SHACK-2",
|
|
};
|
|
|
|
Assert.Equal("14025.0 by SHACK-2, 41m ago", SpotDescription.Of(spot, Now));
|
|
}
|
|
}
|