Apply code formatting cleanup across the monitor projects

- Wrap using directives in `#region` blocks across the Battery, Boiler and NordPool sources and tests
- Expand single-statement guards and loops into braced blocks
- Realign wrapped method arguments, chained calls and continuations
- Replace target-typed `new()` with explicit generic construction and empty string literals with `string.Empty`
- Flatten the boiler config expression and reindent the remaining touched files
This commit is contained in:
2026-12-01 12:33:31 +02:00
parent 77458383d1
commit f919d6b25b
115 changed files with 3115 additions and 1959 deletions
@@ -1,9 +1,13 @@
#region
using FluentAssertions;
using Microsoft.Extensions.Logging;
using Moq;
using NordPool.Models;
using NordPoolManager;
#endregion
namespace NordPool.Manager.Tests;
public class CheapestIntervalsFinderTests
@@ -13,7 +17,7 @@ public class CheapestIntervalsFinderTests
private static readonly DateTime DayStart = NordPoolTestData.DayStart;
private static readonly DateTime DeadlineEndOfDay = DayStart.AddDays(1);
private readonly Mock<ILogger<CheapestIntervalsFinder>> _loggerMock = new();
private readonly Mock<ILogger<CheapestIntervalsFinder>> _loggerMock = new Mock<ILogger<CheapestIntervalsFinder>>();
private CheapestIntervalsFinder CreateSut()
{
@@ -26,7 +30,7 @@ public class CheapestIntervalsFinderTests
}
private static NordPoolPrice CreatePricesForDay(DateTime dayStart,
int intervalCount = NordPoolConsts.MaxDailyIntervals)
int intervalCount = NordPoolConsts.MaxDailyIntervals)
{
return new NordPoolPrice
{
@@ -55,7 +59,7 @@ public class CheapestIntervalsFinderTests
#region FindCheapestIntervals
public static TheoryData<string, double[], int, double, double, int> FilteringCases => new()
public static TheoryData<string, double[], int, double, double, int> FilteringCases => new TheoryData<string, double[], int, double, double, int>
{
{ "deadline includes interval ending exactly at it", [4.93, 5.63, 6.20], 10, double.MaxValue, 1_800.0, 2 },
{ "deadline excludes interval ending one second late", [4.93, 5.63, 6.20], 10, double.MaxValue, 1_799.0, 1 },
@@ -236,12 +240,13 @@ public class CheapestIntervalsFinderTests
{
// Arrange — duplicate payload entries are not deduplicated
var sut = CreateSut();
var prices = new NordPoolPrice
{
Prices = new List<NordPoolDayPrice>
{
new() { Start = DayStart, End = DayStart.AddMinutes(15), Price = 6.20 },
new() { Start = DayStart, End = DayStart.AddMinutes(15), Price = 6.20 }
new NordPoolDayPrice { Start = DayStart, End = DayStart.AddMinutes(15), Price = 6.20 },
new NordPoolDayPrice { Start = DayStart, End = DayStart.AddMinutes(15), Price = 6.20 }
}
};
@@ -258,15 +263,16 @@ public class CheapestIntervalsFinderTests
{
// Arrange
var sut = CreateSut();
var prices = new NordPoolPrice
{
Prices = new List<NordPoolDayPrice>
{
new() { Start = DayStart, End = DayStart.AddMinutes(15), Price = 8.96 },
new() { Start = DayStart.AddMinutes(15), End = DayStart.AddMinutes(30), Price = null },
new() { Start = DayStart.AddMinutes(30), End = DayStart.AddMinutes(45), Price = 6.20 },
new() { Start = null, End = DayStart.AddMinutes(60), Price = 4.93 },
new() { Start = DayStart.AddMinutes(60), End = null, Price = 5.63 }
new NordPoolDayPrice { Start = DayStart, End = DayStart.AddMinutes(15), Price = 8.96 },
new NordPoolDayPrice { Start = DayStart.AddMinutes(15), End = DayStart.AddMinutes(30), Price = null },
new NordPoolDayPrice { Start = DayStart.AddMinutes(30), End = DayStart.AddMinutes(45), Price = 6.20 },
new NordPoolDayPrice { Start = null, End = DayStart.AddMinutes(60), Price = 4.93 },
new NordPoolDayPrice { Start = DayStart.AddMinutes(60), End = null, Price = 5.63 }
}
};
@@ -287,12 +293,12 @@ public class CheapestIntervalsFinderTests
const double priceCap = 12.0;
var expected = prices.Prices!
.Where(p => p.Price <= priceCap)
.OrderBy(p => p.Price)
.ThenBy(p => p.Start)
.Take(requestedIntervals)
.OrderBy(p => p.Start)
.ToList();
.Where(p => p.Price <= priceCap)
.OrderBy(p => p.Price)
.ThenBy(p => p.Start)
.Take(requestedIntervals)
.OrderBy(p => p.Start)
.ToList();
// Act
var result = sut.FindCheapestIntervals(prices, requestedIntervals, priceCap, DeadlineEndOfDay);
@@ -315,30 +321,31 @@ public class CheapestIntervalsFinderTests
{
// Arrange - xUnit cannot serialize CheapestIntervalResult rows, so the matrix is exercised in one test
var sut = CreateSut();
(string Scenario, int NowSeconds, CheapestIntervalResult[] Intervals, bool Expected)[] cases =
[
("inside interval", 10 * Hour + 7 * 60, [Interval(10 * Hour, 10 * Hour + Quarter)], true),
("exactly at start", 10 * Hour, [Interval(10 * Hour, 10 * Hour + Quarter)], true),
("exactly at end", 10 * Hour + Quarter, [Interval(10 * Hour, 10 * Hour + Quarter)], false),
("outside all intervals", 12 * Hour,
[Interval(10 * Hour, 10 * Hour + Quarter), Interval(14 * Hour, 14 * Hour + Quarter)], false),
[Interval(10 * Hour, 10 * Hour + Quarter), Interval(14 * Hour, 14 * Hour + Quarter)], false),
("boundary between adjacent intervals", 10 * Hour + Quarter,
[
Interval(10 * Hour, 10 * Hour + Quarter, 8.96),
Interval(10 * Hour + Quarter, 10 * Hour + 2 * Quarter, 6.20, 2)
], true),
[
Interval(10 * Hour, 10 * Hour + Quarter, 8.96),
Interval(10 * Hour + Quarter, 10 * Hour + 2 * Quarter, 6.20, 2)
], true),
("unsorted intervals", 14 * Hour + 5 * 60,
[Interval(14 * Hour, 14 * Hour + Quarter, 4.93, 2), Interval(10 * Hour, 10 * Hour + Quarter, 6.20)],
true),
[Interval(14 * Hour, 14 * Hour + Quarter, 4.93, 2), Interval(10 * Hour, 10 * Hour + Quarter, 6.20)],
true),
("before first interval", 10 * Hour - 1, [Interval(10 * Hour, 10 * Hour + Quarter)], false),
("in gap between intervals", 10 * Hour + 2 * Quarter,
[Interval(10 * Hour, 10 * Hour + Quarter), Interval(11 * Hour, 11 * Hour + Quarter)], false),
[Interval(10 * Hour, 10 * Hour + Quarter), Interval(11 * Hour, 11 * Hour + Quarter)], false),
("middle of three consecutive intervals", 10 * Hour + Quarter + 5 * 60,
[
Interval(10 * Hour, 10 * Hour + Quarter, rank: 1),
Interval(10 * Hour + Quarter, 10 * Hour + 2 * Quarter, rank: 2),
Interval(10 * Hour + 2 * Quarter, 10 * Hour + 3 * Quarter, rank: 3)
], true),
[
Interval(10 * Hour, 10 * Hour + Quarter, rank: 1),
Interval(10 * Hour + Quarter, 10 * Hour + 2 * Quarter, rank: 2),
Interval(10 * Hour + 2 * Quarter, 10 * Hour + 3 * Quarter, rank: 3)
], true),
("empty interval list", 12 * Hour, [], false)
];