The wheel steps along the span list and keeps the frequency under the pointer in place. With Centre on VFO off, the slice stays put until the receiver nears an edge. The span and the toggle are saved in the settings. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
65 lines
1.9 KiB
C#
65 lines
1.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);
|
|
}
|
|
}
|