Files
Nonemm/tests/Nonemm.Session.Tests/ContestSessionTests.cs
ericek111 1c118f9ce4 Lay the menu bar out the way N1MM lays it out, and fill in the Edit menu
The menu tree comes from N1MM's EntryWindow.Designer.cs: File, Edit, View,
Tools, Config, Window, with the items under the names N1MM gives them. The
window list moved out of View into Window; the call history file moved from
Config into File > Import. Ctrl+W, Ctrl+L and Ctrl+M now work, so the keys
printed in the menu are real. Two commands that had no menu item before:
the CW and SSB function key definitions, and the QTC setup area.

The rest of the Edit menu:

- Ctrl+N asks for a note and puts it in the comment of the contact in the
  boxes, or of the last logged contact when nothing is typed.
- Edit Current Contact opens the Edit Contact form over what is typed but
  not logged. Update hands the values back to the entry boxes.
- Ctrl+Q and Ctrl+A load a logged contact into the boxes and paint them
  pale yellow. Enter writes the change back, Esc puts back what was being
  typed, and stepping forward past the newest contact leaves quick edit.
- Ctrl+U raises the received serial, or a numeric exchange box when the
  contest has no serial.
- Ctrl+F shows the call being typed in the log window, then the next
  contact with that call.

RadioPosition is now OperatingPosition: it is the operator at one radio,
not a place on a band.

Looked at under Xvfb on a 3775-contact log: quick edit back and forward,
Esc, the note dialog, find, and Edit Current Contact putting a zone back
into the entry boxes.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-28 12:18:37 +00:00

117 lines
3.4 KiB
C#

using Nonemm.Contests;
using Nonemm.Contests.Rules;
using Nonemm.Core;
using Nonemm.Core.Country;
using Nonemm.Storage;
namespace Nonemm.Session.Tests;
/// Two radios sharing one contest.
public class ContestSessionTests
{
private static readonly StationInfo Me = new()
{
Callsign = "DL1ABC",
CqZone = 14,
Continent = "EU",
CountryPrefix = "DL",
};
private static ContestSession Session()
{
FakeLogStore store = new();
ContestInstance instance = store.AddContest(new ContestInstance
{
ContestNumber = 0,
ContestName = "CQWPXCW",
});
return new ContestSession(store, new CqWpx(ModeCategory.Cw), instance, Me, null);
}
private static void Type(OperatingPosition radio, string call, string number)
{
radio.Entry.Call = call;
radio.Entry.Set(ExchangeSlot.ReceivedReport, "599");
radio.Entry.Set(ExchangeSlot.SerialNumber, number);
}
[Fact]
public void BothRadiosLogIntoTheSameLog()
{
ContestSession session = Session();
OperatingPosition first = new(session, 1);
OperatingPosition second = new(session, 2);
Type(first, "JA1XYZ", "1");
first.LogContact();
Type(second, "W3LPL", "2");
second.LogContact();
Assert.Equal(2, session.Log.Qsos.Count);
Assert.Equal([1, 2], session.Log.Qsos.Select(q => q.RadioNumber));
}
/// Serial numbers belong to the station, not to a radio, so the second
/// radio carries on where the first left off.
[Fact]
public void SerialNumbersCountUpAcrossBothRadios()
{
ContestSession session = Session();
OperatingPosition first = new(session, 1);
OperatingPosition second = new(session, 2);
Type(first, "JA1XYZ", "1");
Assert.Equal(1, first.LogContact().SentNumber);
Type(second, "W3LPL", "2");
Assert.Equal(2, second.LogContact().SentNumber);
}
/// A station worked on radio 1 is a dupe on radio 2, or the second radio
/// spends the contest working stations again.
[Fact]
public void AStationWorkedOnOneRadioIsADupeOnTheOther()
{
ContestSession session = Session();
OperatingPosition first = new(session, 1);
OperatingPosition second = new(session, 2);
Type(first, "JA1XYZ", "1");
first.LogContact();
Type(second, "JA1XYZ", "2");
Assert.True(second.Verdict()?.IsDupe);
}
/// The two radios are on different bands and are running or searching
/// independently, so neither of those can be shared.
[Fact]
public void EachRadioKeepsItsOwnFrequencyAndRunState()
{
ContestSession session = Session();
OperatingPosition first = new(session, 1);
OperatingPosition second = new(session, 2);
first.Tune(Frequency.FromKilohertz(14_025));
first.IsRunning = true;
second.Tune(Frequency.FromKilohertz(7_025));
Assert.Equal(14_025_000, first.Frequency.Hertz);
Assert.Equal(7_025_000, second.Frequency.Hertz);
Assert.True(first.IsRunning);
Assert.False(second.IsRunning);
}
[Fact]
public void WhatIsTypedOnOneRadioStaysThere()
{
ContestSession session = Session();
OperatingPosition first = new(session, 1);
OperatingPosition second = new(session, 2);
Type(first, "JA1XYZ", "1");
Assert.Equal("", second.Entry.Call);
}
}