public void SwitchOn_TurnedOn()
        {
            var provider = new DeterministicDateTimeProvider();

            provider.Time = () => new DateTime(2000, 1, 1, 1, 0, 0);
            var timer = new TimedSwitcherProvider(provider);

            timer.AddOnTime(new TimeSpanRange(new TimeSpan(0, 0, 0), new TimeSpan(3, 0, 0)));
            var actual   = timer.ShouldBeOn();
            var expected = true;

            Assert.Equal(expected, actual);
        }
        public void SwitchOn_IsOnTrue()
        {
            //arrange
            var dateTimeProvider = new DeterministicDateTimeProvider();
            var dateTime         = new DateTime(2000, 1, 1, 12, 12, 12);

            dateTimeProvider.Time = () => { return(dateTime); };

            //act
            var output = dateTimeProvider.UtcNow();

            //assert
            Assert.Equal(dateTime, output);
        }
        public void SwitchAddOnTime_OnTimeAdded()
        {
            //Arrange
            var provider = new DeterministicDateTimeProvider();

            provider.Time = () => new DateTime(2000, 1, 1, 1, 0, 0);
            var timer = new TimedSwitcherProvider(provider);
            var range = new TimeSpanRange(new TimeSpan(0, 0, 0), new TimeSpan(0, 0, 1));

            //Act
            timer.AddOnTime(range);

            //Assert
            var actual   = timer.OnTimes.First();
            var expected = range;

            Assert.Equal(expected, actual);
        }
        public void SwitchRemoveOnTimeWithRemoveDifferentInstantationToAdd_OnTimeRemoved()
        {
            //Arrange
            var provider = new DeterministicDateTimeProvider();

            provider.Time = () => new DateTime(2000, 1, 1, 1, 0, 0);
            var timer  = new TimedSwitcherProvider(provider);
            var range1 = new TimeSpanRange(new TimeSpan(0, 0, 0), new TimeSpan(0, 0, 1));
            var range2 = new TimeSpanRange(new TimeSpan(0, 0, 0), new TimeSpan(0, 0, 1));

            timer.AddOnTime(range1);

            //Act
            timer.RemoveOnTime(range2);

            //Assert
            var actual   = timer.OnTimes.Count();
            var expected = 0;

            Assert.Equal(expected, actual);
        }