示例#1
0
        public void TestThreadBasedChargeBottomBoundsInOneUpdate()
        {
            BatteryBase battery = new ThreadBasedBattery();

            battery.UpdateCharge(-101);
            Assert.IsTrue(battery.Charge <= 100 && battery.Charge >= 0);
        }
示例#2
0
        public void TestDischargingThreadBased()
        {
            BatteryBase battery     = new ThreadBasedBattery();
            int         startCharge = battery.Charge;

            Thread.Sleep(3000);
            Assert.IsTrue(battery.Charge < startCharge);
        }
示例#3
0
        public void TestThreadBasedChargeBottomBoundsInManyUpdates()
        {
            BatteryBase battery = new ThreadBasedBattery();

            for (int i = 0; i < 101; i++)
            {
                battery.UpdateCharge(-1);
            }
            Assert.IsTrue(battery.Charge <= 100 && battery.Charge >= 0);
        }