Esempio n. 1
0
        public void RepeatMaxReturnsModifiedAction()
        {
            var action       = new SwitchboardAction(true, DateTime.MaxValue);
            var repeatAction = action.Repeat(DateTime.UtcNow);

            Assert.AreNotEqual(action, repeatAction);
        }
Esempio n. 2
0
        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);
        }
Esempio n. 3
0
        public void RemainingSecondsOnRepeatActionReturnsIntMax()
        {
            var remaining = new SwitchboardAction(true, DateTime.MaxValue)
                            .Repeat(DateTime.UtcNow)
                            .GetRemainingOnSeconds(DateTime.UtcNow);

            Assert.AreEqual(int.MaxValue, remaining);
        }
Esempio n. 4
0
        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);
        }
Esempio n. 5
0
        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);
        }
Esempio n. 6
0
        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);
        }