public void EpochTimeSettingUnormalTest() { ClientConfiguration conf = new ClientConfiguration(); // Set custom time-adjust to local time after substracting 30 minutes, // Note that valid time offset is 15 minutes. var timeSpan = DateTime.UtcNow.AddMinutes(-30).Subtract(EpochTime); var localTicks = (long)timeSpan.TotalSeconds; conf.SetCustomEpochTicks(localTicks); AssertRequestTimeTooSkewed(conf); // Set custom time-adjust to local time after adding 30 minutes, // Note that valid time offset is 15 minutes. timeSpan = DateTime.UtcNow.AddMinutes(30).Subtract(EpochTime); localTicks = (long)timeSpan.TotalSeconds; conf.SetCustomEpochTicks(localTicks); AssertRequestTimeTooSkewed(conf); }
public void EpochTimeSettingNormalTest() { ClientConfiguration conf = new ClientConfiguration(); // Set custom time-adjust to local time on the assumption that // the local time is correct standard BEIJING time. var timeSpan = DateTime.UtcNow.Subtract(EpochTime); var localTicks = (long)timeSpan.TotalSeconds; conf.SetCustomEpochTicks(localTicks); AssertRequestTimeValidatity(conf); // Set custom time-adjust to local time after substracting 10 minutes. timeSpan = DateTime.UtcNow.AddMinutes(-10).Subtract(EpochTime); localTicks = (long)timeSpan.TotalSeconds; conf.SetCustomEpochTicks(localTicks); AssertRequestTimeValidatity(conf); // Set custom time-adjust to local time after adding 10 minutes. timeSpan = DateTime.UtcNow.AddMinutes(10).Subtract(EpochTime); localTicks = (long)timeSpan.TotalSeconds; conf.SetCustomEpochTicks(localTicks); AssertRequestTimeValidatity(conf); }