- 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>
66 lines
1.7 KiB
C#
66 lines
1.7 KiB
C#
// SPDX-License-Identifier: GPL-3.0-only
|
|
// Copyright (C) 2026 poli0981 - additional terms under GPLv3 section 7: see NOTICE
|
|
|
|
using System.Diagnostics.CodeAnalysis;
|
|
using FrameLedger.Application.Telemetry;
|
|
|
|
namespace FrameLedger.Infrastructure.Tests.Telemetry;
|
|
|
|
/// <summary>A scripted <see cref="IGpuTelemetrySource"/>: whatever sample it is told to publish next.</summary>
|
|
internal sealed class FakeLayer : IGpuTelemetrySource
|
|
{
|
|
private GpuSample? _next;
|
|
private Func<GpuSample?>? _script;
|
|
|
|
public FakeLayer(TelemetryLayer layer) => Layer = layer;
|
|
|
|
public TelemetryLayer Layer { get; }
|
|
|
|
public GpuCapabilities Capabilities { get; set; }
|
|
|
|
public bool IsDisabled { get; set; }
|
|
|
|
public int Reads { get; private set; }
|
|
|
|
public bool Disposed { get; private set; }
|
|
|
|
public FakeLayer Publish(GpuSample? sample)
|
|
{
|
|
_next = sample;
|
|
_script = null;
|
|
if (sample is not null)
|
|
{
|
|
Capabilities |= sample.PresentFields;
|
|
}
|
|
|
|
return this;
|
|
}
|
|
|
|
public FakeLayer Script(Func<GpuSample?> script)
|
|
{
|
|
_script = script;
|
|
return this;
|
|
}
|
|
|
|
public GpuSample Sample(DateTimeOffset takenAt, double? load = null, double? vram = null, double? temp = null,
|
|
double? power = null, string? adapter = null) => new()
|
|
{
|
|
TakenAt = takenAt,
|
|
Layer = Layer,
|
|
AdapterName = adapter,
|
|
LoadPct = load,
|
|
VramAdapterMb = vram,
|
|
TempCoreC = temp,
|
|
PowerW = power,
|
|
};
|
|
|
|
public bool TryRead([NotNullWhen(true)] out GpuSample? sample)
|
|
{
|
|
Reads++;
|
|
sample = _script is null ? _next : _script();
|
|
return sample is not null;
|
|
}
|
|
|
|
public void Dispose() => Disposed = true;
|
|
}
|