mirror of
https://github.com/ajisaacs/OpenNest.git
synced 2026-10-28 18:21:08 -04:00
File > New restarted its counter every day while names only carry the year, so the first nest of each day was always N26-223, and each PC kept its own counter. In Database mode the nest server now hands out the year's next number (POST /api/nest-names/next, nest_sequences table, schema v6), staying above every stored generated name so offline or pre-existing names are never reissued. The per-PC counter remains the fallback when the server is unreachable or older, resets per year, and is raised past each server allocation. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
34 lines
976 B
C#
34 lines
976 B
C#
using OpenNest.Data;
|
|
|
|
namespace OpenNest.Tests.Data;
|
|
|
|
public class NestNamesTests
|
|
{
|
|
[Theory]
|
|
[InlineData(0, "N26-222")]
|
|
[InlineData(1, "N26-223")]
|
|
[InlineData(29, "N26-22Z")]
|
|
[InlineData(30, "N26-232")]
|
|
[InlineData(900, "N26-322")]
|
|
[InlineData(27000, "N26-3222")]
|
|
public void NamesUseTwoDigitYearAndPaddedBase30Sequence(int number, string expected)
|
|
{
|
|
Assert.Equal(expected, NestNames.Format(2026, number));
|
|
Assert.True(NestNames.TryParse(expected, 2026, out var parsed));
|
|
Assert.Equal(number, parsed);
|
|
}
|
|
|
|
[Theory]
|
|
[InlineData(null)]
|
|
[InlineData("")]
|
|
[InlineData("N25-223")]
|
|
[InlineData("N26-23")]
|
|
[InlineData("N26-2223")]
|
|
[InlineData("N26-22B")]
|
|
[InlineData("n26-223")]
|
|
[InlineData("N26-223 copy")]
|
|
[InlineData("N26-ZZZZZZZZZ")]
|
|
public void TryParse_RejectsOtherYearsAndNonCanonicalNames(string? name) =>
|
|
Assert.False(NestNames.TryParse(name, 2026, out _));
|
|
}
|