Files
Nonemm/tests/Nonemm.Spotting.Tests/SpotDescriptionTests.cs
T
erikbrockoandClaude Sonnet 5.5 58f417a1fb Shorten the bandmap hover text to frequency, spotter, age and comment
The first line reads "14025.0 by K1TTT, 41m ago". The comment follows
on a second line and is left out when it is only LSB, USB or SSB.
Control characters are removed from the comment: cluster lines end in
bell and carriage-return characters, which the tooltip drew as boxes.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-24 11:51:13 +00:00

63 lines
1.9 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)));
}
}