public void Discharge() { int minCharge = 0; FakeInOut fakeInOut = new FakeInOut(); int capacity = 5000; int chargingTime = 60; int charge = 50; Battery battery = new Battery(capacity, chargingTime, fakeInOut); battery.ShowCharge += (s, c) => { charge = c; if (c <= 0) { battery.CanDischarge = false; } }; battery.Discharge(1); if (charge == 0) { battery.CanDischarge = true; battery.Discharge(1); } Assert.AreEqual(charge, minCharge); }
public void StartChargeTask() { int maxCharge = 100; int resultCharge = 0; FakeInOut fakeInOut = new FakeInOut(); int capacity = 5000; int chargingTime = 60; int charge = 99; bool isCall = false; Battery battery = new BatteryTask(capacity, chargingTime, fakeInOut); battery.ShowCharge += (s, c) => { resultCharge = c; isCall = true; }; battery.Charge = charge; battery.StartCharge(1); for (int i = 0; (i < 100) && (!isCall); i++) { Thread.Sleep(2); } Assert.IsTrue(isCall); Assert.AreEqual(resultCharge, maxCharge); }
public void PowerSupply() { FakeInOut fakeInOut = new FakeInOut(); Charger headsetIPhone = new Charger(fakeInOut); fakeInOut.FakeWrite = ""; headsetIPhone.PowerSupply(new object()); var expectedString = $"{nameof(Charger)} connected to USB, charging mobile device"; Assert.AreEqual(expectedString, fakeInOut.FakeWrite); }
public void StartCharge() { int maxCharge = 100; FakeInOut fakeInOut = new FakeInOut(); int capacity = 5000; int chargingTime = 60; int charge = 0; Battery battery = new Battery(capacity, chargingTime, fakeInOut); battery.ShowCharge += (s, c) => charge = c; battery.StartCharge(1); if (charge == 100) { battery.StartCharge(1); } Assert.AreEqual(charge, maxCharge); }
public void Create() { fakeInOut = new FakeInOut(); }
public void Create() { fakeInOut = new FakeInOut(); simCorpMobile = new SimCorpMobile(fakeInOut); }