This commit is contained in:
2026-06-28 13:58:35 +03:00
parent 8f45028715
commit e6bf8258bb
114 changed files with 4365 additions and 874 deletions
@@ -29,17 +29,17 @@ public class NordPoolPriceServiceTests
#region GetTimeQuarterIndex
[Theory]
[InlineData(0, 0, 4)]
[InlineData(1, 0, 8)]
[InlineData(6, 0, 28)]
[InlineData(12, 0, 52)]
[InlineData(23, 0, 0)]
[InlineData(23, 15, 1)]
[InlineData(23, 30, 2)]
[InlineData(23, 45, 3)]
[InlineData(0, 0, 8)] // UTC 00:00 = CEST 02:00
[InlineData(1, 0, 12)] // UTC 01:00 = CEST 03:00
[InlineData(6, 0, 32)] // UTC 06:00 = CEST 08:00
[InlineData(12, 0, 56)] // UTC 12:00 = CEST 14:00
[InlineData(22, 0, 0)] // UTC 22:00 = CEST 00:00 (next day start)
[InlineData(22, 15, 1)] // UTC 22:15 = CEST 00:15
[InlineData(22, 30, 2)] // UTC 22:30 = CEST 00:30
[InlineData(22, 45, 3)] // UTC 22:45 = CEST 00:45
public void GetTimeQuarterIndex_ShouldReturnCorrectIndex(int hour, int minute, int expectedIndex)
{
// Arrange
// Arrange — 2026-03-31 is in CEST (UTC+2)
var testDate = new DateTime(2026, 3, 31, hour, minute, 0, DateTimeKind.Utc);
// Act
@@ -50,14 +50,14 @@ public class NordPoolPriceServiceTests
}
[Theory]
[InlineData(0, 15, 5)]
[InlineData(1, 30, 10)]
[InlineData(12, 0, 52)]
[InlineData(23, 0, 0)]
[InlineData(23, 59, 3)]
[InlineData(0, 15, 9)] // UTC 00:15 = CEST 02:15
[InlineData(1, 30, 14)] // UTC 01:30 = CEST 03:30
[InlineData(12, 0, 56)] // UTC 12:00 = CEST 14:00
[InlineData(22, 0, 0)] // UTC 22:00 = CEST 00:00
[InlineData(22, 59, 3)] // UTC 22:59 = CEST 00:59
public void GetTimeQuarterIndex_ShouldHandleAllHoursCorrectly(int hour, int minute, int expectedIndex)
{
// Arrange
// Arrange — 2026-03-31 is in CEST (UTC+2)
var testDate = new DateTime(2026, 3, 31, hour, minute, 0, DateTimeKind.Utc);
// Act
@@ -68,23 +68,23 @@ public class NordPoolPriceServiceTests
}
[Fact]
public void GetTimeQuarterIndex_AtExactMidnight_ShouldReturnIndex4()
public void GetTimeQuarterIndex_AtUtcMidnight_ShouldReturnCestOffset()
{
// Arrange
// Arrange — UTC 00:00 = CEST 02:00 -> index 8
var testDate = new DateTime(2026, 3, 31, 0, 0, 0, DateTimeKind.Utc);
// Act
var result = NordPoolPriceService.GetTimeQuarterIndex(testDate);
// Assert
result.Should().Be(4);
result.Should().Be(8);
}
[Fact]
public void GetTimeQuarterIndex_AtEndOfDay_ShouldReturnIndex95()
public void GetTimeQuarterIndex_AtEndOfCestDay_ShouldReturnIndex95()
{
// Arrange
var testDate = new DateTime(2026, 3, 31, 22, 45, 0, DateTimeKind.Utc);
// Arrange — CEST 23:45 = UTC 21:45 -> index 95
var testDate = new DateTime(2026, 3, 31, 21, 45, 0, DateTimeKind.Utc);
// Act
var result = NordPoolPriceService.GetTimeQuarterIndex(testDate);
@@ -111,7 +111,7 @@ public class NordPoolPriceServiceTests
[Fact]
public void GetTimeQuarterIndex_ShouldReturn96UniqueQuartersPerDay()
{
// Arrange & Act
// Arrange & Act — iterate over a full UTC day; CET conversion produces 96 unique quarter indices
var indices = new HashSet<int>();
for (var hour = 0; hour < 24; hour++)
{
@@ -129,6 +129,21 @@ public class NordPoolPriceServiceTests
indices.Max().Should().Be(95);
}
[Theory]
[InlineData(2026, 1, 15, 8, 0, 36)] // CET winter (UTC+1): UTC 08:00 = CET 09:00 -> index 36
[InlineData(2026, 7, 15, 8, 0, 40)] // CEST summer (UTC+2): UTC 08:00 = CEST 10:00 -> index 40
public void GetTimeQuarterIndex_ShouldHandleDaylightSavingTimeCorrectly(int year, int month, int day, int hour, int minute, int expectedIndex)
{
// Arrange
var testDate = new DateTime(year, month, day, hour, minute, 0, DateTimeKind.Utc);
// Act
var result = NordPoolPriceService.GetTimeQuarterIndex(testDate);
// Assert
result.Should().Be(expectedIndex);
}
#endregion
#region PriceCorrection