public void NotChargeThreadTest()
        {
            var mobile = new ModernMobile(new NullOutput(), new BackgroundWorkerFactoryMethod(BackgroundWorkerFactoryMethod.WorkerType.Thread));

            float initialCharge = mobile.Battery.ChargeWh;

            Thread.Sleep(5000);

            Assert.IsTrue(initialCharge > mobile.Battery.ChargeWh);
        }
        public void ChargeTaskTest()
        {
            var mobile = new ModernMobile(new NullOutput(), new BackgroundWorkerFactoryMethod(BackgroundWorkerFactoryMethod.WorkerType.Task));

            float initialCharge = mobile.Battery.ChargeWh;

            mobile.Charge(new OrdinaryCharger(new NullOutput()));

            Thread.Sleep(5000);

            Assert.IsTrue(initialCharge < mobile.Battery.ChargeWh);
        }
Ejemplo n.º 3
0
        static void Main(string[] args)
        {
            var scMobile = new SimCorpMobile();

            scMobile.Screen.Show(new Image());
            Console.WriteLine(scMobile);

            Console.WriteLine();

            var modernMobile = new ModernMobile();

            modernMobile.Screen.Show(new Image());
            Console.WriteLine(modernMobile);

            Console.WriteLine("\nPress any key to continue . . .");
            Console.ReadKey();
        }
Ejemplo n.º 4
0
        public static void Main(string[] args)
        {
            var mobile = new ModernMobile(output);

            while (true)
            {
                Console.WriteLine("\n============================");
                Console.WriteLine("Select device: (Esc to exit)");
                Console.WriteLine($"{DEVICE_HEADPHONES} - Headphones");
                Console.WriteLine($"{DEVICE_CHARGER} - Charger");

                ConsoleKeyInfo userInput = Console.ReadKey();
                Console.WriteLine();
                if (userInput.Key == ConsoleKey.Escape)
                {
                    if (!ConfirmationPopup("You are going to exit."))
                    {
                        continue;
                    }
                    return;
                }

                switch (userInput.KeyChar)
                {
                case DEVICE_HEADPHONES:
                    AbstractCreator <PlaybackBase> playbackCreator = playbackCreators[ChooseCreator("Choose playback:", playbackCreators)];
                    mobile.PlaybackComponent = playbackCreator.Creator.Invoke();

                    mobile.Play(new object());
                    break;

                case DEVICE_CHARGER:
                    AbstractCreator <ChargerBase> chargerCreator = chargerCreators[ChooseCreator("Choose charger:", chargerCreators)];
                    ChargerBase charger = chargerCreator.Creator.Invoke();

                    charger?.Charge(mobile);
                    break;

                default:
                    Console.WriteLine("Unexpected input. Please try again.");
                    continue;
                }
            }
        }