ME-MarvinE / XCalendar

A plugin for .NET providing an API for representing a calendar along with fully customisable calendar controls for Xamarin Forms and .NET MAUI
MIT License
300 stars 36 forks source link

Fix DateTimeExtensions tests failing due to culture-specific parameters not being passed #161

Closed ME-MarvinE closed 1 year ago

ME-MarvinE commented 1 year ago

Methods such as FirstDayOfWeek specify an optional parameter "startingDayOfWeek" of type DayOfWeek which affects the result of the calculation. If this isn't specified, it uses CultureInfo.CurrentCulture.DateTimeFormat.FirstDayOfWeek which could vary depending on what machine the tests are run on.

Since the result varies with the machine's culture but the inputs don't, and the tests were created on a machine using a culture with a different start of week than mine, the tests failed.

Added an additional parameter to the test inputs and set the inputs to DayOfWeek.Sunday since the tests passed when CultureInfo.InvariantCulture.DateTimeFormat.FirstDayOfWeek was passed and that was its value.