- NOTICE: copyright, GPL-3.0-only, and three additional terms of the kinds section 7 permits - (b) preserve the notices and the attribution in the program's legal notices, (c) mark a modified version as different and do not call it "FrameLedger" alone, (e) no trademark rights in the name. Shipped as licenses\NOTICE.txt; release.yml refuses a published tree without it. - Section 7 wants additional terms named in the source files: every first-party .cs .cpp .h .inl .ps1 .xaml file (1,053; src/native/third_party excluded) opens with the SPDX line and a pointer to NOTICE. tools/notice-check.ps1 is the gate (six self-test cases, both directions; -Fix writes a missing header) and tools/resx-gen.ps1 generates the string accessors with the header. - The native VERSIONINFO LegalCopyright said GPL-3.0-or-later; it now names the real licence. - CONTRIBUTING.md, FORKING.md, CODE_OF_CONDUCT.md (Contributor Covenant 2.1 by reference), legal/TRADEMARKS.md. - 12_BUILD gate list, CLAUDE.md layout and conventions. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
84 lines
3.4 KiB
C#
84 lines
3.4 KiB
C#
// SPDX-License-Identifier: GPL-3.0-only
|
|
// Copyright (C) 2026 poli0981 - additional terms under GPLv3 section 7: see NOTICE
|
|
|
|
using System.Reflection;
|
|
using FluentAssertions;
|
|
using FrameLedger.Domain.Detection;
|
|
|
|
namespace FrameLedger.Domain.Tests;
|
|
|
|
/// <summary>
|
|
/// The two rules that keep static detection from doing damage: it may not state
|
|
/// a runtime fact, and it may not overwrite a human.
|
|
/// </summary>
|
|
public sealed class StaticDetectionResultTests
|
|
{
|
|
/// <summary>
|
|
/// Names that would mean this type had started reporting what the game is
|
|
/// DOING rather than what it IS.
|
|
/// </summary>
|
|
private static readonly string[] _runtimeFactFragments =
|
|
[
|
|
"upscaler", "fgmode", "framegen", "rtflag", "ptflag", "rrflag",
|
|
"renderwidth", "renderheight", "outputwidth", "outputheight",
|
|
"quality", "latency", "framerate", "fps",
|
|
];
|
|
|
|
[Fact]
|
|
public void NoMemberStatesARuntimeFact()
|
|
{
|
|
// 05_DETECTION: "a static hint may never set a runtime fact". The old
|
|
// design blurred these and produced the field errors that motivated the
|
|
// whole rewrite, so the boundary is enforced rather than described.
|
|
foreach (PropertyInfo p in typeof(StaticDetectionResult).GetProperties())
|
|
{
|
|
foreach (string fragment in _runtimeFactFragments)
|
|
{
|
|
p.Name.Should().NotContainEquivalentOf(fragment,
|
|
$"StaticDetectionResult.{p.Name} looks like a runtime fact; static hints populate " +
|
|
"library metadata and capability chips, never sessions.*");
|
|
}
|
|
}
|
|
}
|
|
|
|
[Fact]
|
|
public void CapabilityIdsAreShippedHints_NotMeasurements()
|
|
{
|
|
// The type-level half of the same rule: capabilities are ids of things
|
|
// the game SHIPS. If this ever becomes a richer type carrying, say, a
|
|
// factor or a preset, that is the moment to re-read 05_DETECTION.
|
|
PropertyInfo caps = typeof(StaticDetectionResult).GetProperty(nameof(StaticDetectionResult.CapabilityIds))!;
|
|
|
|
caps.PropertyType.Should().Be<IReadOnlyList<string>>();
|
|
}
|
|
|
|
// ---- never overwrite a human -------------------------------------------
|
|
|
|
[Fact]
|
|
public void ARerunMayOverwriteAValueItDetectedItself() =>
|
|
StaticDetectionResult.ShouldWrite(DetectionProvenance.Detected, "unity").Should().BeTrue();
|
|
|
|
[Fact]
|
|
public void ARerunMayNotOverwriteAUserSuppliedValue() =>
|
|
StaticDetectionResult.ShouldWrite(DetectionProvenance.UserSupplied, "unity").Should().BeFalse();
|
|
|
|
[Fact]
|
|
public void UnknownProvenanceIsTreatedAsUserSupplied()
|
|
{
|
|
// The safe direction. Of the two ways to be wrong, badging a human's
|
|
// typed value as auto-detected is a lie they cannot see through;
|
|
// failing to badge a detected value merely costs a badge.
|
|
StaticDetectionResult.ShouldWrite(DetectionProvenance.Unknown, "unity").Should().BeFalse();
|
|
((int)DetectionProvenance.Unknown).Should().Be(0, "a default must land on the cautious side");
|
|
}
|
|
|
|
[Fact]
|
|
public void NothingDetectedNeverOverwritesAnything()
|
|
{
|
|
// "Not established" is not "absent". Writing null over a good value on a
|
|
// run where the probe simply could not look would lose data.
|
|
StaticDetectionResult.ShouldWrite(DetectionProvenance.Detected, null).Should().BeFalse();
|
|
StaticDetectionResult.ShouldWrite(DetectionProvenance.UserSupplied, null).Should().BeFalse();
|
|
}
|
|
}
|