public void RepeatMaxReturnsModifiedAction() { var action = new SwitchboardAction(true, DateTime.MaxValue); var repeatAction = action.Repeat(DateTime.UtcNow); Assert.AreNotEqual(action, repeatAction); }
public void TimeToTurnOffOnMaxViaVectorReturnsDateTimeMax() { var samples = new SwitchboardAction(true, DateTime.MaxValue).ToVectorSamples("port", DateTime.UtcNow); var actionFromVector = SwitchboardAction.FromVectorSamples( new NewVectorReceivedArgs(samples.ToDictionary(s => s.Name, s => s.Value)), "port"); Assert.AreEqual(DateTime.MaxValue, actionFromVector.TimeToTurnOff); }
public void RemainingSecondsOnRepeatActionReturnsIntMax() { var remaining = new SwitchboardAction(true, DateTime.MaxValue) .Repeat(DateTime.UtcNow) .GetRemainingOnSeconds(DateTime.UtcNow); Assert.AreEqual(int.MaxValue, remaining); }
public void RemainingSecondsOnTimeWithTicksViaVectorReturnsFullSeconds() { var vectorTime = new DateTime(2021, 6, 22, 12, 5, 2, 333).AddTicks(42); var samples = new SwitchboardAction(true, vectorTime.AddSeconds(10)).ToVectorSamples("port", vectorTime); var actionFromVector = SwitchboardAction.FromVectorSamples(new NewVectorReceivedArgs(samples.ToDictionary(s => s.Name, s => s.Value)), "port"); var remaining = actionFromVector.GetRemainingOnSeconds(vectorTime); Assert.AreEqual(10, remaining); }
public void RemainingSecondsOnMaxViaVectorReturnsIntMax() { var samples = new SwitchboardAction(true, DateTime.MaxValue).ToVectorSamples("port", DateTime.UtcNow); var actionFromVector = SwitchboardAction.FromVectorSamples( new NewVectorReceivedArgs(samples.ToDictionary(s => s.Name, s => s.Value)), "port"); var remaining = actionFromVector.GetRemainingOnSeconds(DateTime.UtcNow); Assert.AreEqual(int.MaxValue, remaining); }
public void RemainingSecondsAfter9SecondsAnd800MillisecondsReturns1Second() { var vectorTime = new DateTime(2021, 6, 22, 12, 5, 2, 333).AddTicks(1); var samples = new SwitchboardAction(true, vectorTime.AddSeconds(10)).ToVectorSamples("port", vectorTime); var actionFromVector = SwitchboardAction.FromVectorSamples(new NewVectorReceivedArgs(samples.ToDictionary(s => s.Name, s => s.Value)), "port"); var remaining = actionFromVector.GetRemainingOnSeconds(vectorTime.AddSeconds(9).AddMilliseconds(800)); Assert.AreEqual(1, remaining); }