public void MaxChargeTest() { double capacity = 3000; BaseBattery battery = new LiIonBattery(capacity, 1500); battery.ChargeChanged += DummyMethod; battery.Charge(capacity + 1); Assert.AreEqual(100, battery.GetCurrentCharge()); }
public void TaskChargeTest() { double capacity = 3000; BaseBattery battery = new LiIonBattery(capacity, 1500); battery.ChargeChanged += DummyMethod; double expCharge = 52; Task charge = new Task(() => { battery.Charge(50); } ); charge.Start(); charge.Wait(); double resCharge = battery.GetCurrentCharge(); Assert.AreEqual(expCharge, resCharge); }