Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
        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);
        }
Ejemplo n.º 4
0
        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);
        }
Ejemplo n.º 5
0
 public void Create()
 {
     fakeInOut = new FakeInOut();
 }
Ejemplo n.º 6
0
 public void Create()
 {
     fakeInOut     = new FakeInOut();
     simCorpMobile = new SimCorpMobile(fakeInOut);
 }