24729ee267
- Reindent appsettings.json and the MSBuild project files - Collapse single-statement guard blocks and tidy using and member order - Normalize XML doc indentation and file endings - Reorder BatteryMonitor test-data helpers and move the exclusion tests into their own region - Carry the same formatting through the boiler config, control, entity and test files
48 lines
1.6 KiB
C#
48 lines
1.6 KiB
C#
using NordPool.Models;
|
|
|
|
namespace NordPool.Manager.Tests;
|
|
|
|
/// <summary>
|
|
/// Shared, deterministic datasets used by the NordPool tests.
|
|
/// Keeping the generators here avoids copy-pasted price loops across test classes.
|
|
/// </summary>
|
|
internal static class NordPoolTestData
|
|
{
|
|
public static readonly DateTime DayStart = new(2026, 3, 31, 0, 0, 0, DateTimeKind.Utc);
|
|
|
|
/// <summary>
|
|
/// Builds a contiguous set of 15-minute intervals starting at <paramref name="dayStart" />.
|
|
/// </summary>
|
|
public static List<NordPoolDayPrice> CreateIntervals(
|
|
int count,
|
|
Func<int, double?> priceFactory,
|
|
DateTime? dayStart = null)
|
|
{
|
|
var start = dayStart ?? DayStart;
|
|
|
|
return
|
|
[
|
|
.. Enumerable.Range(0, count)
|
|
.Select(i => new NordPoolDayPrice
|
|
{
|
|
Start = start.AddMinutes(i * NordPoolConsts.MinutesPerInterval),
|
|
End = start.AddMinutes((i + 1) * NordPoolConsts.MinutesPerInterval),
|
|
Price = priceFactory(i)
|
|
})
|
|
];
|
|
}
|
|
|
|
/// <summary>
|
|
/// A full 96-interval day with a deterministic sawtooth price curve covering
|
|
/// negative, zero, cheap and expensive prices.
|
|
/// </summary>
|
|
public static List<NordPoolDayPrice> CreateGeneratedDay(DateTime? dayStart = null)
|
|
{
|
|
var start = dayStart ?? DayStart;
|
|
|
|
return CreateIntervals(
|
|
NordPoolConsts.MaxDailyIntervals,
|
|
i => Math.Round(15.0 * Math.Sin(i / 6.0) + i % 8 - 2.0, 2),
|
|
start);
|
|
}
|
|
} |