Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

the end date is set to 1st of next month as the upperbound is excluded #170

Merged
merged 2 commits into from
Dec 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ internal IReadOnlyList<Partition> GetPartitionsForCurrentAndAdjacentMonths()
internal (DateOnly startDate, DateOnly endDate) GetMonthStartAndEndDate(DateOnly date)
{
DateOnly startDate = new DateOnly(date.Year, date.Month, 1);
DateOnly endDate = startDate.AddMonths(1).AddDays(-1);
DateOnly endDate = startDate.AddMonths(1);
return (startDate, endDate);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ public void GetPartitionsForCurrentAndAdjacentMonths_ReturnsCorrectPartitions()

// Assert
Assert.Equal(6, partitions.Count);
Assert.Contains(partitions, p => p.Name == "eventlogv1_y2023m09" && p.StartDate == new DateOnly(2023, 9, 1) && p.EndDate == new DateOnly(2023, 9, 30));
Assert.Contains(partitions, p => p.Name == "eventlogv1_y2023m10" && p.StartDate == new DateOnly(2023, 10, 1) && p.EndDate == new DateOnly(2023, 10, 31));
Assert.Contains(partitions, p => p.Name == "eventlogv1_y2023m11" && p.StartDate == new DateOnly(2023, 11, 1) && p.EndDate == new DateOnly(2023, 11, 30));
Assert.Contains(partitions, p => p.Name == "eventlogv1_y2023m09" && p.StartDate == new DateOnly(2023, 9, 1) && p.EndDate == new DateOnly(2023, 10, 1));
Assert.Contains(partitions, p => p.Name == "eventlogv1_y2023m10" && p.StartDate == new DateOnly(2023, 10, 1) && p.EndDate == new DateOnly(2023, 11, 1));
Assert.Contains(partitions, p => p.Name == "eventlogv1_y2023m11" && p.StartDate == new DateOnly(2023, 11, 1) && p.EndDate == new DateOnly(2023, 12, 1));
}

[Theory]
[InlineData(2023, 10, 15, 2023, 10, 1, 2023, 10, 31)]
[InlineData(2023, 2, 1, 2023, 2, 1, 2023, 2, 28)]
[InlineData(2024, 2, 1, 2024, 2, 1, 2024, 2, 29)] // Leap year
[InlineData(2023, 10, 15, 2023, 10, 1, 2023, 11, 1)]
[InlineData(2023, 2, 1, 2023, 2, 1, 2023, 3, 1)]
[InlineData(2024, 2, 1, 2024, 2, 1, 2024, 3, 1)]
public void GetMonthStartAndEndDate_ReturnsCorrectDates(int year, int month, int day, int expectedStartYear, int expectedStartMonth, int expectedStartDay, int expectedEndYear, int expectedEndMonth, int expectedEndDay)
{
// Arrange
Expand All @@ -55,8 +55,8 @@ public void GetPartitionsForCurrentAndAdjacentMonths_CrossYearBoundary_ReturnsCo

// Assert
Assert.Equal(6, partitions.Count);
Assert.Contains(partitions, p => p.Name == "eventlogv1_y2023m11" && p.StartDate == new DateOnly(2023, 11, 1) && p.EndDate == new DateOnly(2023, 11, 30));
Assert.Contains(partitions, p => p.Name == "eventlogv1_y2023m12" && p.StartDate == new DateOnly(2023, 12, 1) && p.EndDate == new DateOnly(2023, 12, 31));
Assert.Contains(partitions, p => p.Name == "eventlogv1_y2024m01" && p.StartDate == new DateOnly(2024, 1, 1) && p.EndDate == new DateOnly(2024, 1, 31));
Assert.Contains(partitions, p => p.Name == "eventlogv1_y2023m11" && p.StartDate == new DateOnly(2023, 11, 1) && p.EndDate == new DateOnly(2023, 12, 1));
Assert.Contains(partitions, p => p.Name == "eventlogv1_y2023m12" && p.StartDate == new DateOnly(2023, 12, 1) && p.EndDate == new DateOnly(2024, 1, 1));
Assert.Contains(partitions, p => p.Name == "eventlogv1_y2024m01" && p.StartDate == new DateOnly(2024, 1, 1) && p.EndDate == new DateOnly(2024, 2, 1));
}
}
Loading