Exemplo n.º 1
0
        public void TestThreadBasedChargeBottomBoundsInOneUpdate()
        {
            BatteryBase battery = new ThreadBasedBattery();

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

            Thread.Sleep(3000);
            Assert.IsTrue(battery.Charge < startCharge);
        }
Exemplo n.º 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);
        }