sancsoft / hq

Harlequin management system
MIT License
1 stars 1 forks source link

Add DateOnlyExtensions and add unit tests for the calculations #120

Closed rmaffitsancsoft closed 3 months ago

rmaffitsancsoft commented 3 months ago

For example, I would expect the following to be true based on recent changes to the week calculations when generating PSRs:

var today = new DateOnly(2024, 6, 12);
var weekStart = today.GetPeriodStartDate(Period.Week);
var weekEnd = today.GetPeriodStartDate(Period.Week);

// The following should be true and validated in a test, week should calculate Saturday - Friday
weekStart == new DateOnly(2024, 6, 8)
weekEnd == new DateOnly(2024, 6, 14)
public static DateOnly GetPeriodStartDate(this DateOnly forDate, Period period)
{
  // switch on period
}

public static DateOnly GetPeriodEndDate(this DateOnly forDate, Period period)
{
  // switch on period
}
rmaffitsancsoft commented 3 months ago

https://xunit.net/docs/getting-started/netcore/cmdline

We may be able to use [InlineData] to pass our date/expected start/expected end values to ease the use. We should have a couple test cases per period that test:

  1. If forDate is on the start of the period
  2. If forDate is somewhere in the middle of the period
  3. If forDate is on the end of the period
rmaffitsancsoft commented 3 months ago

Image

rmaffitsancsoft commented 3 months ago

https://nodatime.org/