public SendManySms()
        {
            InitializeComponent();

            smsPhone1 = new SmsPhone(FormFactor.Bar, "BP20200406");
            smsPhone1.AddSimCard(new SimCard(), output);
            smsPhone2 = new SmsPhone(FormFactor.Bar, "BP20200409");
            smsPhone2.AddSimCard(new SimCard(), output);
            smsPhone3 = new SmsPhone(FormFactor.Bar, "BP20200406");
            smsPhone3.AddSimCard(new SimCard(), output);
            smsPhone4 = new SmsPhone(FormFactor.Bar, "BP20200409");
            smsPhone4.AddSimCard(new SimCard(), output);

            output = new TextBoxOutput(this.receivedSms);

            var contact1 = smsPhone1.GetMyContact("Alex");
            var contact2 = smsPhone2.GetMyContact("Vova");
            var contact3 = smsPhone3.GetMyContact("Stas");
            var contact4 = smsPhone4.GetMyContact("Oleg");

            smsPhone1.AddContact(contact2, contact3, contact4);
            smsPhone2.AddContact(contact1);
            smsPhone3.AddContact(contact1);
            smsPhone4.AddContact(contact1);

            phones = new IPhone[] { smsPhone1, smsPhone2, smsPhone3, smsPhone4 };

            smsFormatting.DataSource = Enum.GetNames(typeof(TextBoxOutput.FormatingStyle));
            cmbWords.DataSource      = new List <string>()
            {
                FILTER_ALL_VALUES
            }.Concat(words).ToArray();
            cmbLogic.DataSource  = Enum.GetNames(typeof(LogicOperand));
            dtpFrom.CustomFormat = "dd/MM/yyyy hh:mm:ss";
            dtpTo.CustomFormat   = "dd/MM/yyyy hh:mm:ss";

            resetFilters();

            sendSms = delegate
            {
                int arrLength = words.Length - 1;
                smsPhone1.SendSms($"smsVSO|{words[random.Next(arrLength)]}|{smsCount++}", output, 0, "Vova", "Stas", "Oleg");
                smsPhone2.SendSms($"smsVA|{words[random.Next(arrLength)]}|{smsCount++}", output, 0, "Alex");
                smsPhone3.SendSms($"smsSA|{words[random.Next(arrLength)]}|{smsCount++}", output, 0, "Alex");
                smsPhone4.SendSms($"smsOA|{words[random.Next(arrLength)]}|{smsCount++}", output, 0, "Alex");

                cbxSubscribers.DataSource = getAllSenders(phones);
            };

            powerbank             = new PowerBank("PB20200430");
            powerbank.PluginToUse = Plugins.Usb;
        }
        public async Task PowerBankOutputTest()
        {
            IPhone gamePhone = new GamePhone(FormFactor.Bar, "BP20200321");

            IOutput output = new outputTest();

            IInterconnection powerBank = new PowerBank("BP20200325");

            powerBank.PluginToUse = Plugins.Usb;

            await gamePhone.PluginDevice(powerBank, (i) => { output.WriteLine($"Phone is charging by {nameof(PowerBank)}"); }).ExecuteDevice <PowerBank>(executeTimes: 1);

            Assert.AreEqual("Phone is charging by PowerBank\n", writtenText);
        }
        public async Task PowerIsSupplied()
        {
            IPhone phone = new SmsPhone(FormFactor.Bar, "SP20200502");

            IInterconnection powerBank = new PowerBank("PB20200502");

            powerBank.PluginToUse = Plugins.Usb;

            int originalCapacity = phone.UseComponent <Battery>().Capacity;

            await phone.PluginDevice(powerBank).ExecuteDevice <PowerBank>(executeTimes: 2);

            int chargedCapacity = phone.UseComponent <Battery>().Capacity;

            Assert.IsTrue(originalCapacity < 100);
            Assert.IsTrue(originalCapacity < chargedCapacity);
        }
Beispiel #4
0
        static void Main(string[] args)
        {
            IPhone gamePhone = new GamePhone(FormFactor.Bar, "BP20200321");

            IOutput output = new ConsoleOutput();

            IInterconnection headsetSony = new HeadsetSony("BP20200321");

            Action <int> headsetAction = (i) => { output.WriteLine("HeadsetSony in Action"); };

            IInterconnection powerBank = new PowerBank("BP20200325");

            powerBank.PluginToUse = Plugins.Usb;

            Console.WriteLine("Select device to connect with the phone:");
            Console.WriteLine($"(1): {headsetSony}. Connected by bluetooth");
            Console.WriteLine($"(2): {headsetSony}. Connected by jack 3.5 mm");
            Console.WriteLine($"(3): {powerBank}");
            Console.WriteLine("Enter choice number");

            int choice;

            Int32.TryParse(Console.ReadLine(), out choice);

            switch (choice)
            {
            case 1:
                headsetSony.PluginToUse = Plugins.Bluetooth;
                gamePhone.PluginDevice(headsetSony, headsetAction).ExecuteDevice <HeadsetSony>();
                break;

            case 2:
                headsetSony.PluginToUse = Plugins.HeadSetJack35;
                gamePhone.PluginDevice(headsetSony, headsetAction).ExecuteDevice <HeadsetSony>();
                break;

            case 3:
                gamePhone.PluginDevice(powerBank, (i) => { output.WriteLine($"Phone is charging by {nameof(PowerBank)}"); }).ExecuteDevice <PowerBank>(executeTimes: 1);
                break;

            default:
                output.WriteLine("Unknown device selected");
                break;
            }
        }
        public async Task MaximumCapacityIs100()
        {
            IPhone phone = new SmsPhone(FormFactor.Bar, "SP20200502");

            IInterconnection powerBank = new PowerBank("PB20200502");

            powerBank.PluginToUse = Plugins.Usb;

            phone.UseComponent <Battery>().Capacity = 100;

            int maximumCapacity = phone.UseComponent <Battery>().Capacity;

            await phone.PluginDevice(powerBank).ExecuteDevice <PowerBank>(executeTimes: 2);

            int chargedCapacity = phone.UseComponent <Battery>().Capacity;

            Assert.IsTrue(maximumCapacity == 100);
            Assert.IsTrue(maximumCapacity == chargedCapacity);
        }
Beispiel #6
0
 //private Slider slider;
 void Awake()
 {
     ship  = GetComponent <Ship>();
     pBank = GetComponent <PowerBank>();
     fBar  = GetComponent <FuelBar>();
 }
        public SendSmsReceiveCalls()
        {
            InitializeComponent();

            outputEvents = new TextBoxOutput(this.receivedEvents);

            phone1 = new SmsCallPhone(FormFactor.Bar, "BP20200406");
            phone1.AddSimCard(new SimCard(), outputEvents);

            phone2 = new SmsCallPhone(FormFactor.Bar, "BP20200409");
            phone2.AddSimCard(new SimCard(), outputEvents);

            phone3 = new SmsCallPhone(FormFactor.Bar, "BP20200406");
            phone3.AddSimCard(new SimCard(), outputEvents);

            phone41 = new SmsCallPhone(FormFactor.Bar, "BP20200409");
            phone41.AddSimCard(new SimCard(), outputEvents);

            phone42 = new SmsCallPhone(FormFactor.Bar, "BP20200507");
            phone42.AddSimCard(new SimCard(), outputEvents);

            phone5 = new SmsCallPhone(FormFactor.Bar, "BP20200511");
            phone5.AddSimCard(new SimCard(), outputEvents);
            phone5.AddSimCard(new SimCard(), outputEvents);

            var contact1  = phone1.GetMyContact("Alex");
            var contact2  = phone2.GetMyContact("Vova");
            var contact3  = phone3.GetMyContact("Stas");
            var contact41 = phone41.GetMyContact("Oleg");
            var contact42 = phone42.GetMyContact("Oleg");
            var contact51 = phone5.GetMyContact("Roma");
            var contact52 = phone5.GetMyContact("Roma", 1);

            phone1.AddContact(contact2, contact42, contact51, contact52);
            phone2.AddContact(contact1);
            phone3.AddContact(contact1);
            phone41.AddContact(contact1);
            phone42.AddContact(contact1);
            phone5.AddContact(contact1);

            phones = new IPhone[] { phone1, phone2, phone3, phone41, phone42, phone5 };

            smsFormatting.DataSource = Enum.GetNames(typeof(TextBoxOutput.FormatingStyle));
            cmbWords.DataSource      = new List <string>()
            {
                FILTER_ALL_VALUES
            }.Concat(words).ToArray();
            cmbLogic.DataSource  = Enum.GetNames(typeof(LogicOperand));
            dtpFrom.CustomFormat = "dd/MM/yyyy hh:mm:ss";
            dtpTo.CustomFormat   = "dd/MM/yyyy hh:mm:ss";

            resetFilters();

            sendSms = delegate
            {
                int arrLength = words.Length - 1;
                phone1.SendSms($"smsVSOR|{words[random.Next(arrLength)]}|{smsCount++}", outputEvents, 0, "Vova", "Oleg", "Roma");
                phone2.SendSms($"smsVA|{words[random.Next(arrLength)]}|{smsCount++}", outputEvents, 0, "Alex");
                phone3.SendSms($"smsSA|{words[random.Next(arrLength)]}|{smsCount++}", outputEvents, 0, "Alex");
                phone41.SendSms($"smsOA|{words[random.Next(arrLength)]}|{smsCount++}", outputEvents, 0, "Alex");
                phone42.SendSms($"smsOA|{words[random.Next(arrLength)]}|{smsCount++}", outputEvents, 0, "Alex");
                phone5.SetActiveSimCard(0).SendSms($"smsR1A|{words[random.Next(arrLength)]}|{smsCount++}", outputEvents, 0, "Alex");
                phone5.SetActiveSimCard(1).SendSms($"smsR2A|{words[random.Next(arrLength)]}|{smsCount++}", outputEvents, 0, "Alex");

                cbxSubscribers.DataSource = getAllSenders(phones);
            };

            var callers = new IPhone[] { phone2, phone41, phone42, phone5 };
            var callTo  = new string[] { "Vova", "Oleg", "Roma" };

            receiveCalls = delegate
            {
                callers[random.Next(3)].SetActiveSimCard(0).MakeCall(random.Next(300, 3000), "Alex", outputEvents);
                phone1.MakeCall(random.Next(300, 3000), callTo[random.Next(2)], outputEvents);

                phone5.SetActiveSimCard(0).MakeCall(random.Next(300, 3000), "Alex", outputEvents);
                phone5.SetActiveSimCard(1).MakeCall(random.Next(300, 3000), "Alex", outputEvents);

                phone1.MakeCall(random.Next(300, 3000), "Oleg", outputEvents);
                phone1.MakeCall(random.Next(300, 3000), "Roma", outputEvents, 1);
                phone1.MakeCall(random.Next(300, 3000), "Roma", outputEvents);


                phone3.MakeCall(111, "Alex", outputEvents);
                phone3.MakeCall(222, "Alex", outputEvents);

                phone41.MakeCall(333, "Alex", outputEvents);
                phone41.MakeCall(444, "Alex", outputEvents);

                cbxSubscribers.DataSource = getAllCallers(phones);
            };

            powerbank             = new PowerBank("PB20200430");
            powerbank.PluginToUse = Plugins.Usb;
        }