Esempio n. 1
0
        public void SetsLimitTo100()
        {
            wrapper.SetupGet(m => m.Limit).Returns(80);

            FullChargeHandler handler = new FullChargeHandler(wrapper.Object,
                                                              powerStatus.Object,
                                                              timer.Object,
                                                              eventHandler.Object);

            wrapper.VerifySet(m => m.Limit = 100);
        }
Esempio n. 2
0
        public void WaitProportionalTime()
        {
            timer.Setup(m => m.Start(It.IsAny <float>())).Raises(m => m.Elapsed += null, (ElapsedEventArgs)null);
            powerStatus.SetupSequence(m => m.BatteryLifePercent).Returns(0.8f).Returns(0.82f);

            FullChargeHandler handler = new FullChargeHandler(wrapper.Object,
                                                              powerStatus.Object,
                                                              timer.Object,
                                                              eventHandler.Object);

            timer.Verify(m => m.Start(It.IsInRange <float>((9 * 60 * 0.5f * 1000), 9 * 60f * 1000, Range.Inclusive)), Times.Once);
        }
Esempio n. 3
0
        public void WaitUntilChargeChanged()
        {
            timer.Setup(m => m.Start(It.IsAny <float>())).Raises(m => m.Elapsed += null, (ElapsedEventArgs)null);
            powerStatus.SetupSequence(m => m.BatteryLifePercent).Returns(0.8f).Returns(0.8f).Returns(0.8f).Returns(0.99f);

            FullChargeHandler handler = new FullChargeHandler(wrapper.Object,
                                                              powerStatus.Object,
                                                              timer.Object,
                                                              eventHandler.Object);

            timer.Verify(m => m.Start(It.IsAny <float>()), Times.Exactly(3));
            eventHandler.Verify(m => m(It.IsAny <object>(), It.IsAny <EventArgs>()), Times.Once);
        }
Esempio n. 4
0
        public void ResetsLimitToOriginal()
        {
            int original = 80;

            wrapper.SetupGet(m => m.Limit).Returns(original);
            timer.Setup(m => m.Start(It.IsAny <float>())).Raises(m => m.Elapsed += null, (ElapsedEventArgs)null);
            powerStatus.SetupGet(m => m.BatteryLifePercent).Returns(0.99f);

            FullChargeHandler handler = new FullChargeHandler(wrapper.Object,
                                                              powerStatus.Object,
                                                              timer.Object,
                                                              eventHandler.Object);

            wrapper.VerifySet(m => m.Limit = original);
        }