tests(calendar): Add calendar render tests (#3)
- updates calendar to support overriding the current day when rendering - supports current culture when rendering - renames Calendar to CalendarGenerator
This commit is contained in:
parent
ecb0a20cbb
commit
3547e32b6e
29 changed files with 542 additions and 19 deletions
48
tests/ModuleTests/Calendar/BasicRenderTest.cs
Normal file
48
tests/ModuleTests/Calendar/BasicRenderTest.cs
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
using ModuleCore.Calendar;
|
||||
using ModuleTests.Calendar.TestData;
|
||||
using System.Globalization;
|
||||
|
||||
namespace ModuleTests.Calendar;
|
||||
|
||||
public class BasicRenderTest
|
||||
{
|
||||
private static readonly VerifySettings Settings;
|
||||
|
||||
static BasicRenderTest()
|
||||
{
|
||||
Settings = new VerifySettings();
|
||||
var testBaseDirectory = Path.Join(TestConstants.SnapshotFolderName, nameof(BasicRenderTest));
|
||||
|
||||
Settings.UseDirectory(testBaseDirectory);
|
||||
Settings.DisableDiff();
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[ClassData(typeof(CalendarTestDates))]
|
||||
public Task BasicCalendarRender(DateTime month)
|
||||
{
|
||||
Settings.UseFileName($"{month:yyyy-MM-dd}");
|
||||
|
||||
var calendar = new CalendarGenerator();
|
||||
// Render the calendar with the start of the month as the today date so no elapsed marks are shown
|
||||
var renderedMonth = calendar.Render(month, new DateTime(month.Year, month.Month, 1));
|
||||
|
||||
return Verify(renderedMonth, Settings);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[ClassData(typeof(CultureCodeTestData))]
|
||||
public Task CultureInfoCalendarRender(string cultureCode)
|
||||
{
|
||||
Settings.UseFileName($"{cultureCode}");
|
||||
|
||||
Thread.CurrentThread.CurrentCulture = new CultureInfo(cultureCode);
|
||||
|
||||
var month = new DateTime(2026, 8, 1);
|
||||
var calendar = new CalendarGenerator();
|
||||
// Render the calendar with the start of the month as the today date so no elapsed marks are shown
|
||||
var renderedMonth = calendar.Render(month, new DateTime(month.Year, month.Month, 1));
|
||||
|
||||
return Verify(renderedMonth, Settings);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue