ShellContent improvements.
This commit is contained in:
@@ -42,7 +42,7 @@ public class CalendarPageViewModelTests
|
||||
viewModel.CurrentVisibleRange.EndDate.Should().Be(new DateOnly(2026, 3, 22));
|
||||
viewModel.LoadedDateWindow.StartDate.Should().Be(new DateTime(2026, 3, 9));
|
||||
viewModel.LoadedDateWindow.EndDate.Should().Be(new DateTime(2026, 3, 30));
|
||||
viewModel.VisibleDateRangeText.Should().Be("3/16/2026 - 3/22/2026");
|
||||
viewModel.VisibleDateRangeText.Should().Be("March 16 - March 22");
|
||||
|
||||
requestedPeriod.Should().NotBeNull();
|
||||
requestedPeriod!.Start.Should().Be(new DateTime(2026, 3, 9));
|
||||
|
||||
@@ -115,7 +115,7 @@ public class CalendarRangeResolverTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Formatter_Day_UsesSingleDate()
|
||||
public void Formatter_Day_UsesMonthDayPattern()
|
||||
{
|
||||
var formatter = new CalendarRangeTextFormatter();
|
||||
var range = new VisibleDateRange(
|
||||
@@ -131,11 +131,11 @@ public class CalendarRangeResolverTests
|
||||
|
||||
var text = formatter.Format(range, new TestDateContextProvider("en-US", today: new DateOnly(2026, 3, 20)));
|
||||
|
||||
text.Should().Be("3/20/2026");
|
||||
text.Should().Be("March 20");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Formatter_Range_UsesCultureShortDatePattern()
|
||||
public void Formatter_Range_UsesCultureMonthDayPattern()
|
||||
{
|
||||
var formatter = new CalendarRangeTextFormatter();
|
||||
var range = new VisibleDateRange(
|
||||
@@ -159,7 +159,7 @@ public class CalendarRangeResolverTests
|
||||
|
||||
var text = formatter.Format(range, new TestDateContextProvider("de-DE", today: new DateOnly(2026, 3, 20)));
|
||||
|
||||
text.Should().Be("16.03.2026 - 22.03.2026");
|
||||
text.Should().Be("16. März - 22. März");
|
||||
}
|
||||
|
||||
private static CalendarSettings CreateSettings(
|
||||
|
||||
@@ -0,0 +1,103 @@
|
||||
using System.Linq;
|
||||
using FluentAssertions;
|
||||
using Wino.Core.Domain.Enums;
|
||||
using Wino.Core.Domain.Models.Calendar;
|
||||
using Xunit;
|
||||
|
||||
namespace Wino.Core.Tests;
|
||||
|
||||
public class CalendarRangeTextFormatterTests
|
||||
{
|
||||
private static readonly CalendarRangeTextFormatter Formatter = new();
|
||||
private static readonly TestDateContextProvider DateContextProvider = new("en-US", new DateOnly(2026, 3, 24));
|
||||
|
||||
[Fact]
|
||||
public void Format_ReturnsMonthDay_ForSingleDate()
|
||||
{
|
||||
var range = CreateRange(
|
||||
CalendarDisplayType.Day,
|
||||
anchorDate: new DateOnly(2026, 3, 6),
|
||||
startDate: new DateOnly(2026, 3, 6),
|
||||
endDate: new DateOnly(2026, 3, 6));
|
||||
|
||||
Formatter.Format(range, DateContextProvider).Should().Be("March 6");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Format_ReturnsFullRange_ForDatesInSameMonth()
|
||||
{
|
||||
var range = CreateRange(
|
||||
CalendarDisplayType.Week,
|
||||
anchorDate: new DateOnly(2026, 3, 6),
|
||||
startDate: new DateOnly(2026, 3, 3),
|
||||
endDate: new DateOnly(2026, 3, 10));
|
||||
|
||||
Formatter.Format(range, DateContextProvider).Should().Be("March 3 - March 10");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Format_ReturnsFullRange_ForDatesInDifferentMonths()
|
||||
{
|
||||
var range = CreateRange(
|
||||
CalendarDisplayType.Week,
|
||||
anchorDate: new DateOnly(2026, 4, 2),
|
||||
startDate: new DateOnly(2026, 3, 30),
|
||||
endDate: new DateOnly(2026, 4, 7));
|
||||
|
||||
Formatter.Format(range, DateContextProvider).Should().Be("March 30 - April 7");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Format_ReturnsAnchorMonth_WhenVisibleRangeSpansMonthGrid()
|
||||
{
|
||||
var range = CreateRange(
|
||||
CalendarDisplayType.Month,
|
||||
anchorDate: new DateOnly(2026, 3, 12),
|
||||
startDate: new DateOnly(2026, 2, 23),
|
||||
endDate: new DateOnly(2026, 4, 5));
|
||||
|
||||
Formatter.Format(range, DateContextProvider).Should().Be("March 2026");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Format_ReturnsAnchorMonth_WhenVisibleRangeHasExactlyTwentyEightDays()
|
||||
{
|
||||
var range = CreateRange(
|
||||
CalendarDisplayType.Month,
|
||||
anchorDate: new DateOnly(2026, 2, 14),
|
||||
startDate: new DateOnly(2026, 2, 1),
|
||||
endDate: new DateOnly(2026, 2, 28));
|
||||
|
||||
Formatter.Format(range, DateContextProvider).Should().Be("February 2026");
|
||||
}
|
||||
|
||||
private static VisibleDateRange CreateRange(
|
||||
CalendarDisplayType displayType,
|
||||
DateOnly anchorDate,
|
||||
DateOnly startDate,
|
||||
DateOnly endDate)
|
||||
{
|
||||
var dayCount = endDate.DayNumber - startDate.DayNumber + 1;
|
||||
var dates = Enumerable.Range(0, dayCount)
|
||||
.Select(offset => startDate.AddDays(offset))
|
||||
.ToArray();
|
||||
|
||||
return new VisibleDateRange(
|
||||
displayType,
|
||||
anchorDate,
|
||||
startDate,
|
||||
endDate,
|
||||
anchorDate,
|
||||
dayCount,
|
||||
ContainsToday: false,
|
||||
SpansSingleMonth: startDate.Month == endDate.Month && startDate.Year == endDate.Year,
|
||||
Dates: dates);
|
||||
}
|
||||
|
||||
private sealed class TestDateContextProvider(string cultureName, DateOnly today) : IDateContextProvider
|
||||
{
|
||||
public System.Globalization.CultureInfo Culture => System.Globalization.CultureInfo.GetCultureInfo(cultureName);
|
||||
public TimeZoneInfo TimeZone => TimeZoneInfo.Utc;
|
||||
public DateOnly GetToday() => today;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user