public async Task PowerIsConsumed()
        {
            IPhone phone = new SmsPhone(FormFactor.Bar, "SP20200502");

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

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

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

            Assert.IsTrue(originalCapacity > 0);
            Assert.IsTrue(originalCapacity > dischargedCapacity);
        }
        public async Task MinimumCapacityIs0()
        {
            IPhone phone = new SmsPhone(FormFactor.Bar, "SP20200502");

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

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

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

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

            Assert.IsTrue(minimumCapacity == 0);
            Assert.IsTrue(minimumCapacity == dischargedCapacity);
        }
        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);
        }
        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);
        }
        public void MessageWasReceived()
        {
            IPhone            smsPhone1  = new SmsPhone(FormFactor.Bar, "BP20200406");
            IPhone            smsPhone2  = new SmsPhone(FormFactor.Bar, "BP20200409");
            string            tesString  = "TEST STRING";
            MockTextBoxOutput mockoutput = new MockTextBoxOutput(richTextBox);

            Action <SmsMessage> subscribe = smsPhone2.UseComponent <Communicator>().SmsSubscribe(mockoutput);

            smsPhone1.UseComponent <Communicator>().SetRecipient(subscribe).SendSms(tesString);

            Assert.IsTrue(methodCalled == 1, $"Method {nameof(mockoutput.WriteLine)} must be called once");
        }
Esempio n. 6
0
        public void FilteringSms(string subString, string receivedFrom, LogicOperand logic, string fromTo, int expectedResults)
        {
            DateTime from, to;

            SetDates(fromTo, out from, out to);

            GeneralPhone smsPhone1 = new SmsPhone(FormFactor.Bar, "BP20200406");

            smsPhone1.AddSimCard(new SimCard());
            GeneralPhone smsPhone2 = new SmsPhone(FormFactor.Bar, "BP20200409");

            smsPhone2.AddSimCard(new SimCard());

            var contact2 = smsPhone2.GetMyContact("Vova");

            smsPhone1.AddContact(contact2);

            int i = 0;

            foreach (string word in words)
            {
                smsPhone1.SendSms(smsText: $"Test Message {i++} {word}", names: "Vova");
            }

            FilterParams filterParams = new FilterParams()
            {
                SubString    = subString,
                ReceivedFrom = receivedFrom,
                Logic        = logic,
                From         = from,
                To           = to
            };
            Func <IEnumerable <GeneralPhone>, FilterParams, ListViewItem[]> filterChanged = UpdateFiltering;

            ListViewItem[] lvItems = filterChanged(new List <GeneralPhone>()
            {
                smsPhone1, smsPhone2
            }, filterParams);

            Assert.AreEqual(words.Length, smsPhone1.UseComponent <Memory>().Get <SmsMessage>().Count());
            Assert.AreEqual(words.Length, smsPhone2.UseComponent <Memory>().Get <SmsMessage>().Count());
            Assert.AreEqual(expectedResults, lvItems.Count());
        }