public async void CanSetDateTimeSwitch(int timeOffset, DateTimeSwitchType type, bool expected) { var dt = DateTime.UtcNow.AddMinutes(timeOffset); var @switch = new DateTimeSwitchableAttribute(dt, type); var isOn = await @switch.IsEnabledForRequest(null); Assert.AreEqual(expected, isOn); }
public DateTimeSwitchableAttribute(string switchingTime, DateTimeSwitchType type = DateTimeSwitchType.Activate) { this.SwitchingTime = ParseDateTime(switchingTime); this.Type = type; }
/// <summary> /// Creates a new instance of the <see cref="DateTimeSwitchableAttribute" /> /// instance. /// </summary> /// <param name="feature"> /// The feature controlled by this switch. /// </param> /// <param name="switchingTime"> /// The time at which the feature is to be switched on or off. /// Note that this is compared against DateTime.UtcNow. /// </param> /// <param name="type"> /// The type of switch: whether the feature is to be switched on or off. /// </param> public DateTimeSwitchableAttribute(DateTime switchingTime, DateTimeSwitchType type = DateTimeSwitchType.Activate) { this.SwitchingTime = switchingTime; this.Type = type; }