Apply code formatting cleanup across monitor projects

- 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
This commit is contained in:
2026-11-30 11:52:06 +02:00
parent cf8c9434c8
commit 24729ee267
165 changed files with 2513 additions and 2470 deletions
@@ -1,3 +1,4 @@
using System.Text;
using System.Text.Json;
using FluentAssertions;
using NordPool.Models;
@@ -14,6 +15,18 @@ public class CompactNordPoolDayPriceTests
private static readonly long TestStartEpoch = new DateTimeOffset(TestStart).ToUnixTimeSeconds();
private static readonly long TestEndEpoch = new DateTimeOffset(TestEnd).ToUnixTimeSeconds();
public static TheoryData<string, string> InvalidJsonPayloads => new()
{
{ "empty array", "[]" },
{ "too few elements", "[1,2]" },
{ "extra elements", "[1,2,3,4]" },
{ "missing end of array", "[1,2,3" },
{ "non-numeric start", "[\"abc\",2,3]" },
{ "non-numeric end", "[1,\"abc\",3]" },
{ "non-numeric price", "[1,2,\"abc\"]" },
{ "object instead of array", "{\"start\":1}" }
};
[Fact]
public void FromDayPrice_ShouldConvertDateTimesToUnixEpochSeconds()
{
@@ -150,7 +163,9 @@ public class CompactNordPoolDayPriceTests
var json = JsonSerializer.Serialize(prices);
json.Should().Be($"[[{TestStartEpoch},{TestEndEpoch},12.5],[{TestEndEpoch},{TestEndEpoch + IntervalDurationSeconds},13.26]]");
json.Should()
.Be(
$"[[{TestStartEpoch},{TestEndEpoch},12.5],[{TestEndEpoch},{TestEndEpoch + IntervalDurationSeconds},13.26]]");
}
[Fact]
@@ -161,18 +176,6 @@ public class CompactNordPoolDayPriceTests
act.Should().Throw<ArgumentNullException>();
}
public static TheoryData<string, string> InvalidJsonPayloads => new()
{
{ "empty array", "[]" },
{ "too few elements", "[1,2]" },
{ "extra elements", "[1,2,3,4]" },
{ "missing end of array", "[1,2,3" },
{ "non-numeric start", "[\"abc\",2,3]" },
{ "non-numeric end", "[1,\"abc\",3]" },
{ "non-numeric price", "[1,2,\"abc\"]" },
{ "object instead of array", "{\"start\":1}" }
};
[Theory]
[MemberData(nameof(InvalidJsonPayloads))]
public void JsonDeserialization_WithInvalidPayload_ShouldThrowJsonException(string scenario, string json)
@@ -237,7 +240,8 @@ public class CompactNordPoolDayPriceTests
result.Should().HaveCount(96);
result.Should().BeInAscendingOrder(p => p.Start);
result[0].Start.Should().Be(new DateTimeOffset(NordPoolTestData.DayStart).ToUnixTimeSeconds());
result[95].Start.Should().Be(new DateTimeOffset(NordPoolTestData.DayStart.AddMinutes(95 * MinutesPerInterval)).ToUnixTimeSeconds());
result[95].Start.Should().Be(new DateTimeOffset(NordPoolTestData.DayStart.AddMinutes(95 * MinutesPerInterval))
.ToUnixTimeSeconds());
}
[Fact]
@@ -284,9 +288,9 @@ public class CompactNordPoolDayPriceTests
last_updated = DateTime.UtcNow.ToString("O")
};
var json = JsonSerializer.Serialize(attributePayload);
var byteCount = System.Text.Encoding.UTF8.GetByteCount(json);
var byteCount = Encoding.UTF8.GetByteCount(json);
byteCount.Should().BeLessThan(haAttributeByteLimitBytes,
$"serialized attribute payload is {byteCount} bytes, exceeding HA's {haAttributeByteLimitBytes}-byte limit");
}
}
}