I have a code that compares the last timestamp with the actual timestamp. If the actual timestamp is up to the last timestamp, control the systemβs time. Due to the transition from or to daylight saving time, I work with UTC.
Now I would like to write unit test for this particular situation.
public void TransitionFromDSTToNonDST() { var dayLightChangeEnd= TimeZone.CurrentTimeZone.GetDaylightChanges(DateTime.Now.Year).End; var stillInDaylightSavingTime= dayLightChangeEnd.Subtract(TimeSpan.FromMinutes(62));
But actually I would like to simulate the following:
var stillInDaylightSavingTime = //for example 02.18 am BEFORE switching to Non-DST var noDaylightSavingTimeAnymore = //for example 02.10 am AFTER switching to Non-DST
So, the question is, how can I determine if 02.18 AM is either DST or not.
c # unit-testing mstest
WaltiD
source share