You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Reopen "Fix DueDate.StringDate conversion to and from DateTime." (#41)
* Added FakeLocalTimeZone helper class.
The class is used to change the time zone of the tests upon initialization, and resets it back when disposed.
* Added more tests for DueDate model.
The added tests ensure consistency in StringDate property setter and getter.
* Changed date formatting in DueDate.StringDate property.
Date is now converted using the round-trip format without milliseconds.
Date is also no longer being converted to universal time before formatting.
* Made a simple change in floating due date test.
DateTimeKind is switched to Unspecified instead of Utc since the due date should be treated as floating.
* Fixed date convertion in `DueDate.StringDate` getter.
The fix reverts back to depending on `DueDate.Timezone` property to determine the conversion formatting.
However, it doesn't convert the `DueDate.Date` value to universal time unless the `DueDate` is intended to be fixed.
* Made a simple fix to the "fixed timezone" `DueDate` test.
Timezone info was missing for a fixed date.
* Fixed CreateNewItem_DueDateIsLocal_DueDateNotChanged test.
Since floating due dates are now converted to `Unspecified` date time, the method `ToLocalTime` is no longer used because it assumes the given date as `UTC`.
* Replaced DueDate public constructors with static methods.
Methods include detailed documentation comments.
* Removed redundant checks in DueDate.StringDate getter.
Static methods that are used to instantiate DueDates are now in charge of handling different kinds of dates.
* Updated tests with new DueDate static methods.
* Remove randomization in tests.
Fake time zone random selection is replaced by pre-determined custom offset.
* Remove unnecessary comments.
* Removed unnecessary SuppressFinalize call in DueDateTests.
/// A helper class that changes the local timezone to a fake timezone provided
8
+
/// at initialization, and resets the original local timezone when disposed.
9
+
/// </summary>
10
+
/// <remarks>
11
+
/// See this <see href="https://stackoverflow.com/questions/44413407/mock-the-country-timezone-you-are-running-unit-test-from">SO question</see> for more details.
12
+
/// </remarks>
13
+
publicsealedclassFakeLocalTimeZone:IDisposable
14
+
{
15
+
16
+
/// <summary>
17
+
/// The fake time zone info that has been set as local.
18
+
/// </summary>
19
+
publicTimeZoneInfoFakeTimeZoneInfo{get;}
20
+
21
+
22
+
/// <summary>
23
+
/// Initializes a new instance of the <see cref="FakeLocalTimeZone"/> class.
0 commit comments