Build ErsatzTV Image / Build & test (.NET) (pull_request) Successful in 2m17s
Build ErsatzTV Image / Build & push image (amd64) (pull_request) Has been skipped
Build ErsatzTV Image / Build & test (.NET) (push) Successful in 2m38s
Build ErsatzTV Image / Build & push image (amd64) (push) Successful in 5m41s
NCalcSync 5.11.0 -> 6.3.2 clears CVE-2026-55254 / GHSA-3w5p-95mh-gq75 (the factorial-DoS advisory on NCalc.Core/NCalcSync). NCalc 6 split its assemblies and renamed the custom-function API, so port OpacityExpressionHelper: FunctionArgs -> FunctionEventArgs, and args.Parameters[i].Evaluate() -> args.Parameters.Evaluate(i) (FunctionData.Count / Evaluate(index)). Add a regression test covering the migrated opacity wiring (the feature had no tests). NCalc 6 transitively requires Microsoft.Extensions.Logging.Abstractions >= 10.0.7, so bump the centrally-pinned Microsoft.Extensions.* family 10.0.2 -> 10.0.7 to avoid the NU1605 downgrade error (a .NET 10 servicing patch bump). SQLitePCLRaw: EF Core 9's Sqlite provider pulls the vulnerable bundle 2.1.10 (GHSA-2m69-gcr7-jv3q, outdated bundled SQLite). Directly pin SQLitePCLRaw.bundle_e_sqlite3 3.0.3 in Infrastructure.Sqlite to override the transitive version with the patched native (lib.e_sqlite3 3.50.3); core 3.0.3 satisfies Microsoft.Data.Sqlite's >= 2.1.10 requirement under EF Core 9. Verified: `dotnet list package --vulnerable --include-transitive` reports 0 vulnerable projects; restore + Release build clean; full test suite green under UTC. (2 pre-existing PlayoutModeSchedulerBase filler tests fail only under non-UTC local timezones, unrelated to these deps; they pass in CI.) Refs #8 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
53 lines
2.0 KiB
C#
53 lines
2.0 KiB
C#
using ErsatzTV.Infrastructure.Streaming.Graphics;
|
|
using NCalc;
|
|
using NUnit.Framework;
|
|
using Shouldly;
|
|
|
|
namespace ErsatzTV.Infrastructure.Tests.Streaming.Graphics;
|
|
|
|
[TestFixture]
|
|
public class OpacityExpressionHelperTests
|
|
{
|
|
// Exercises the NCalc custom-function wiring (FunctionEventArgs / FunctionData under NCalc 6.x)
|
|
// exactly the way the graphics elements do: build an Expression, hook EvaluateFunction, evaluate.
|
|
private static float Evaluate(string expressionString, TimeSpan timeOfDay)
|
|
{
|
|
var expression = new Expression(expressionString);
|
|
expression.EvaluateFunction += OpacityExpressionHelper.EvaluateFunction;
|
|
return OpacityExpressionHelper.GetOpacity(
|
|
expression,
|
|
timeOfDay,
|
|
TimeSpan.Zero,
|
|
TimeSpan.Zero,
|
|
TimeSpan.Zero);
|
|
}
|
|
|
|
// LinearFadePoints(time, start=0, peakStart=10, peakEnd=20, end=30)
|
|
[TestCase(5, 0.5)] // fade in: (5-0)/(10-0)
|
|
[TestCase(15, 1.0)] // solid
|
|
[TestCase(25, 0.5)] // fade out: (30-25)/(30-20)
|
|
[TestCase(35, 0.0)] // past end
|
|
public void LinearFadePoints_ReturnsExpectedOpacity(int timeOfDaySeconds, double expected)
|
|
{
|
|
float opacity = Evaluate(
|
|
"LinearFadePoints(time_of_day_seconds, 0, 10, 20, 30)",
|
|
TimeSpan.FromSeconds(timeOfDaySeconds));
|
|
|
|
opacity.ShouldBe((float)expected, 0.0001);
|
|
}
|
|
|
|
// LinearFadeDuration(time, start=0, fadeSeconds=10, peakSeconds=10)
|
|
// -> peakStart=10, peakEnd=20, end=30 (same curve as the LinearFadePoints case above)
|
|
[TestCase(5, 0.5)] // mid fade in
|
|
[TestCase(15, 1.0)] // solid
|
|
[TestCase(25, 0.5)] // mid fade out
|
|
public void LinearFadeDuration_ReturnsExpectedOpacity(int timeOfDaySeconds, double expected)
|
|
{
|
|
float opacity = Evaluate(
|
|
"LinearFadeDuration(time_of_day_seconds, 0, 10, 10)",
|
|
TimeSpan.FromSeconds(timeOfDaySeconds));
|
|
|
|
opacity.ShouldBe((float)expected, 0.0001);
|
|
}
|
|
}
|