Nonemm.Session holds what the operator is typing, what the log says about it and what happens on Enter, with no UI toolkit behind it. Nonemm.Rig talks to hamlib's rigctld and reconnects on its own. Nonemm.Spotting reads DX cluster lines into a bandmap that drops spots after an hour. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
58 lines
1.7 KiB
C#
58 lines
1.7 KiB
C#
using Nonemm.Core;
|
|
using Nonemm.Storage;
|
|
|
|
namespace Nonemm.Session.Tests;
|
|
|
|
/// A log store that keeps everything in memory, so session tests do not need a
|
|
/// file. It keeps the one rule the sqlite store enforces: no two contacts with
|
|
/// the same call in the same second.
|
|
public sealed class FakeLogStore : LogStore
|
|
{
|
|
private readonly List<Qso> qsos = [];
|
|
private readonly List<ContestInstance> contests = [];
|
|
|
|
public IReadOnlyList<ContestInstance> Contests() => contests;
|
|
|
|
public ContestInstance? Contest(int contestNumber) =>
|
|
contests.FirstOrDefault(c => c.ContestNumber == contestNumber);
|
|
|
|
public ContestInstance AddContest(ContestInstance instance)
|
|
{
|
|
ContestInstance stored = instance with { ContestNumber = contests.Count + 1 };
|
|
contests.Add(stored);
|
|
return stored;
|
|
}
|
|
|
|
public void UpdateContest(ContestInstance instance)
|
|
{
|
|
int at = contests.FindIndex(c => c.ContestNumber == instance.ContestNumber);
|
|
contests[at] = instance;
|
|
}
|
|
|
|
public IReadOnlyList<Qso> Qsos(int contestNumber) =>
|
|
qsos.Where(q => q.ContestNumber == contestNumber).OrderBy(q => q.TimestampUtc).ToList();
|
|
|
|
public Qso Add(Qso qso)
|
|
{
|
|
Qso candidate = qso;
|
|
while (qsos.Any(q => q.Call.Text == candidate.Call.Text && q.TimestampUtc == candidate.TimestampUtc))
|
|
{
|
|
candidate = candidate with { TimestampUtc = candidate.TimestampUtc.AddSeconds(1) };
|
|
}
|
|
qsos.Add(candidate);
|
|
return candidate;
|
|
}
|
|
|
|
public void Update(Qso qso)
|
|
{
|
|
int at = qsos.FindIndex(q => q.Id == qso.Id);
|
|
qsos[at] = qso;
|
|
}
|
|
|
|
public void Delete(string id) => qsos.RemoveAll(q => q.Id == id);
|
|
|
|
public void Dispose()
|
|
{
|
|
}
|
|
}
|