Esempio n. 1
0
        protected MobileBase(IOutput output, BackgroundWorkerFactoryMethod backgroundWorkerFactory = null)
        {
            this.output = output;

            SMSProvider.SMSReciever += SMSMessenger.AddMessage;

            var workerFactory = backgroundWorkerFactory ?? new BackgroundWorkerFactoryMethod();

            Battery = new Battery();
            BackgroundWorkerBase discharge = workerFactory.CreateWorker(() => {
                while (true)
                {
                    Thread.Sleep(2500);
                    Battery.ChangeCharge(-Battery.CapacityWh / 100);
                }
            });

            discharge.Start();

            managebleChargeAction = new ManageableAction(new Action(() => {
                Thread.Sleep(1000);
                Battery.ChangeCharge(Charger == null ? 0f : (float)Math.Pow(Charger.ChargeCurrentMa, 2) * 0.00005f);
            }));
            BackgroundWorkerBase charge = workerFactory.CreateWorker(() => managebleChargeAction.ThreadStart());

            charge.Start();
        }
        public void ChangeChargeMinimumTest()
        {
            var battery = new Battery();

            battery.ChangeCharge(-10 * battery.CapacityWh);

            Assert.IsTrue(battery.ChargeWh == 0f);
        }