The zoom list gains 60 kHz and a "mode" level that shows the CW, digital or phone part of the band the receiver is in, before "band". For views from 40 to 200 kHz wide, the scale picks the smallest round step that keeps three lines of text between ticks. The font size buttons are removed; Ctrl with the wheel or plus and minus still change the size. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
95 lines
2.9 KiB
C#
95 lines
2.9 KiB
C#
using Nonemm.Core;
|
|
|
|
namespace Nonemm.Spotting.Tests;
|
|
|
|
public class BandmapSliceTests
|
|
{
|
|
private static Frequency Khz(double kilohertz) => Frequency.FromHertz((long)(kilohertz * 1000));
|
|
|
|
[Fact]
|
|
public void ACentredSliceHasTheReceiverInTheMiddleEvenPastTheBandEdge()
|
|
{
|
|
(Frequency low, Frequency high) = BandmapSlice.Choose(
|
|
Bands.Band20M, Khz(14_348), 20_000, centred: true, previousLow: null);
|
|
|
|
Assert.Equal(Khz(14_338), low);
|
|
Assert.Equal(Khz(14_358), high);
|
|
}
|
|
|
|
[Fact]
|
|
public void ASliceThatDoesNotFollowKeepsItsPlaceWhileTheReceiverIsInside()
|
|
{
|
|
(Frequency low, _) = BandmapSlice.Choose(
|
|
Bands.Band20M, Khz(14_025), 20_000, centred: false, previousLow: Khz(14_010));
|
|
|
|
Assert.Equal(Khz(14_010), low);
|
|
}
|
|
|
|
[Fact]
|
|
public void ASliceThatDoesNotFollowMovesWhenTheReceiverLeaves()
|
|
{
|
|
(Frequency low, _) = BandmapSlice.Choose(
|
|
Bands.Band20M, Khz(14_100), 20_000, centred: false, previousLow: Khz(14_010));
|
|
|
|
Assert.Equal(Khz(14_090), low);
|
|
}
|
|
|
|
[Fact]
|
|
public void AMovedSliceStaysInsideTheBand()
|
|
{
|
|
(Frequency low, _) = BandmapSlice.Choose(
|
|
Bands.Band20M, Bands.Band20M.Low, 20_000, centred: false, previousLow: null);
|
|
|
|
Assert.Equal(Bands.Band20M.Low, low);
|
|
}
|
|
|
|
[Fact]
|
|
public void ASpanOfZeroShowsTheWholeBand()
|
|
{
|
|
(Frequency low, Frequency high) = BandmapSlice.Choose(
|
|
Bands.Band20M, Khz(14_025), 0, centred: true, previousLow: null);
|
|
|
|
Assert.Equal(Bands.Band20M.Low, low);
|
|
Assert.Equal(Bands.Band20M.High, high);
|
|
}
|
|
|
|
[Fact]
|
|
public void ZoomingKeepsTheFrequencyUnderThePointerAtTheSameHeight()
|
|
{
|
|
// the pointer is a quarter of the way down a 40 kHz slice
|
|
Frequency low = BandmapSlice.Zoom(Khz(14_000), 40_000, 20_000, Khz(14_010));
|
|
|
|
Assert.Equal(Khz(14_005), low);
|
|
}
|
|
|
|
private static readonly BandSegments Segments = new(
|
|
Bands.Band20M, CwHigh: Khz(14_150), DigitalLow: Khz(14_070), DigitalHigh: Khz(14_099));
|
|
|
|
[Theory]
|
|
[InlineData(14_025, 14_000, 14_150)]
|
|
[InlineData(14_080, 14_070, 14_099)]
|
|
[InlineData(14_250, 14_150, 14_350)]
|
|
public void ThePartOfTheBandIsTheOneTheReceiverIsIn(double receiver, double low, double high)
|
|
{
|
|
(Frequency from, Frequency to) = BandmapSlice.Part(Bands.Band20M, Segments, Khz(receiver));
|
|
|
|
Assert.Equal((Khz(low), Khz(high)), (from, to));
|
|
}
|
|
|
|
[Fact]
|
|
public void ABandWithoutBoundariesShowsTheWholeBandAsAPart()
|
|
{
|
|
(Frequency from, Frequency to) = BandmapSlice.Part(Bands.Band20M, null, Khz(14_025));
|
|
|
|
Assert.Equal((Bands.Band20M.Low, Bands.Band20M.High), (from, to));
|
|
}
|
|
|
|
[Fact]
|
|
public void ThePartIsStretchedToIncludeAReceiverOutsideTheBand()
|
|
{
|
|
(_, Frequency to) = BandmapSlice.Part(Bands.Band20M, Segments, Khz(14_360));
|
|
|
|
Assert.Equal(Khz(14_360), to);
|
|
}
|
|
}
|