Add the core, contest, storage and format layers
Frequencies, bands, modes, callsigns, grid squares and the country file live in Nonemm.Core. Nonemm.Contests holds the scoring engine and CQ WW and CQ WPX. Nonemm.Storage writes N1MM's DXLOG schema, and Nonemm.Formats writes Cabrillo 3.0 and reads and writes ADIF. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
87
tests/Nonemm.Contests.Tests/CqWorldWideTests.cs
Normal file
87
tests/Nonemm.Contests.Tests/CqWorldWideTests.cs
Normal file
@@ -0,0 +1,87 @@
|
||||
using Nonemm.Contests.Rules;
|
||||
using Nonemm.Core;
|
||||
|
||||
namespace Nonemm.Contests.Tests;
|
||||
|
||||
public class CqWorldWideTests
|
||||
{
|
||||
private static ContestLog LogFor(StationInfo me) =>
|
||||
new(new CqWorldWide(ModeCategory.Cw), me, TestLog.CountryFile);
|
||||
|
||||
[Fact]
|
||||
public void ContactWithOwnCountryScoresNothing()
|
||||
{
|
||||
ContestLog log = LogFor(TestLog.Germany);
|
||||
Assert.Equal(0, log.Judge(TestLog.Contact("DL9XYZ", zone: 14)).Points);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SameContinentDifferentCountryScoresOne()
|
||||
{
|
||||
ContestLog log = LogFor(TestLog.Germany);
|
||||
Assert.Equal(1, log.Judge(TestLog.Contact("IK2XYZ", zone: 15)).Points);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void DifferentContinentScoresThree()
|
||||
{
|
||||
ContestLog log = LogFor(TestLog.Germany);
|
||||
Assert.Equal(3, log.Judge(TestLog.Contact("JA1XYZ", zone: 25)).Points);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void NorthAmericansScoreTwoWithinNorthAmerica()
|
||||
{
|
||||
ContestLog log = LogFor(TestLog.UnitedStates);
|
||||
Assert.Equal(2, log.Judge(TestLog.Contact("VE3XYZ", zone: 5)).Points);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void OwnCountryStillCountsAsAMultiplier()
|
||||
{
|
||||
ContestLog log = LogFor(TestLog.Germany);
|
||||
Verdict verdict = log.Judge(TestLog.Contact("DL9XYZ", zone: 14));
|
||||
Assert.Equal(2, verdict.NewMultipliers.Count);
|
||||
Assert.Equal(0, verdict.Points);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ZoneAndCountryCountOncePerBand()
|
||||
{
|
||||
ContestLog log = LogFor(TestLog.Germany);
|
||||
log.Add(TestLog.Contact("JA1XYZ", zone: 25));
|
||||
Assert.Empty(log.Judge(TestLog.Contact("JA2XYZ", zone: 25)).NewMultipliers);
|
||||
Assert.Equal(2, log.Judge(TestLog.Contact("JA2XYZ", 21_025, zone: 25)).NewMultipliers.Count);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SameStationOnAnotherBandIsNotADupe()
|
||||
{
|
||||
ContestLog log = LogFor(TestLog.Germany);
|
||||
log.Add(TestLog.Contact("JA1XYZ", zone: 25));
|
||||
Assert.True(log.Judge(TestLog.Contact("JA1XYZ", zone: 25)).IsDupe);
|
||||
Assert.False(log.Judge(TestLog.Contact("JA1XYZ", 21_025, zone: 25)).IsDupe);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ScoreIsPointsTimesMultipliers()
|
||||
{
|
||||
ContestLog log = LogFor(TestLog.Germany);
|
||||
log.Add(TestLog.Contact("JA1XYZ", zone: 25));
|
||||
log.Add(TestLog.Contact("PY2XYZ", zone: 11));
|
||||
Assert.Equal(6, log.Tally.Points);
|
||||
Assert.Equal(4, log.Tally.TotalMultipliers);
|
||||
Assert.Equal(24, log.TotalScore);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void RemovingAContactHandsItsMultiplierToTheNextOne()
|
||||
{
|
||||
ContestLog log = LogFor(TestLog.Germany);
|
||||
Qso first = log.Add(TestLog.Contact("JA1XYZ", zone: 25, at: new DateTime(2026, 5, 30, 12, 0, 0, DateTimeKind.Utc)));
|
||||
log.Add(TestLog.Contact("JA2XYZ", zone: 25, at: new DateTime(2026, 5, 30, 12, 1, 0, DateTimeKind.Utc)));
|
||||
log.Remove(first.Id);
|
||||
Assert.True(log.Qsos.Single().IsMultiplier1);
|
||||
Assert.Equal(2, log.Tally.TotalMultipliers);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user