public void TestMessageIsremovedFromStorage() { //Arrange MyMessage message; EmptyMobile MyMobile = new EmptyMobile(); List <MyMessage> expectedList = new List <MyMessage>(); //Act for (int i = 0; i < 5; i++) { message = new MyMessage(); MyMobile.Storage.Add(message); if (i % 2 == 0) { expectedList.Add(message); } } MyMobile.Storage.Remove(3); MyMobile.Storage.Remove(1); //Assert Assert.AreEqual(3, MyMobile.Storage.messageStorage.Count); Assert.IsTrue(expectedList.SequenceEqual(MyMobile.Storage.messageStorage)); }
public void TestAdding_MessageAddedToStorage() { //Arrange MyMessage message = new MyMessage(); EmptyMobile MyMobile = new EmptyMobile(); //Act MyMobile.SMSProvider.ReceiveSMS(message); //Assert Assert.AreEqual(1, MyMobile.Storage.messageStorage.Count()); }
public void TestMessageIsAddedToStorage() { //Arrange MyMessage message = new MyMessage(); EmptyMobile MyMobile = new EmptyMobile(); //Act MyMobile.Storage.Add(message); //Assert Assert.AreEqual(1, MyMobile.Storage.messageStorage.Count); Assert.AreEqual(message, MyMobile.Storage.messageStorage[0]); }
public void ChargeLessThan100Test() { //Arrange EmptyMobile MyMobile = new EmptyMobile(); MyMobile.Battery = new Battery(); MyMobile.Battery.BatteryCharger = BatteryChargerFactoty.GetBatteryType("BatteryChargerWithTreads"); //Act MyMobile.Battery.BatteryCharger.Charger = 105; //Assert Assert.IsTrue(MyMobile.Battery.BatteryCharger.Charger <= 100); }
public void ChargeMoreThen0Test() { //Arrange EmptyMobile MyMobile = new EmptyMobile(); MyMobile.Battery = new Battery(); MyMobile.Battery.BatteryCharger = BatteryChargerFactoty.GetBatteryType("BatteryChargerWithTreads"); //Act MyMobile.Battery.BatteryCharger.Charger = -10; //Assert Assert.IsTrue(MyMobile.Battery.BatteryCharger.Charger >= 0); }
public void TestAdding_MessagesAddedToStorage() { //Arrange MyMessage message; EmptyMobile MyMobile = new EmptyMobile(); //Act for (int i = 0; i < 20; i++) { message = new MyMessage(); MyMobile.SMSProvider.ReceiveSMS(message); } //Assert Assert.AreEqual(20, MyMobile.Storage.messageStorage.Count()); }
public void TestEventRaised() { // Arrange EmptyMobile MyMobile = new EmptyMobile(); Format format = new Format(); FormatDelegate currentFormat; currentFormat = format.FormatType[0]; string unformatedText = "New message"; bool raisedEvent = false; MyMobile.SMSProvider = new SMSProvider(); //Act MyMobile.SMSProvider.SMSReceived += (message) => { raisedEvent = true; }; MyMobile.SMSProvider.ReceiveSMS(format.OnSMSReceived(unformatedText, currentFormat)); //Assert Assert.IsTrue(raisedEvent); }
public void ChargerDecreaseWithTasksTest() { //Arrange EmptyMobile MyMobile = new EmptyMobile(); MyMobile.Battery = new Battery(); MyMobile.Battery.BatteryCharger = BatteryChargerFactoty.GetBatteryType("BatteryChargerWithTask"); int initialChargeValue = 95; CheckBox checkBoxCharge = new CheckBox(); ProgressBar progressBarCharge = new ProgressBar(); //Act checkBoxCharge.Checked = false; MyMobile.Battery.BatteryCharger.Charger = initialChargeValue; MyMobile.Battery.BatteryCharger.executeCharge(checkBoxCharge, progressBarCharge); Thread.Sleep(3000); //Arrange Assert.IsTrue(initialChargeValue > MyMobile.Battery.BatteryCharger.Charger); }
public void ChargerIncreasesWithThreadsTest() { //Arrange EmptyMobile MyMobile = new EmptyMobile(); MyMobile.Battery = new Battery(); MyMobile.Battery.BatteryCharger = BatteryChargerFactoty.GetBatteryType("BatteryChargerWithTreads"); int initialChargeValue = 0; CheckBox checkBoxCharge = new CheckBox(); ProgressBar progressBarCharge = new ProgressBar(); //Act checkBoxCharge.Checked = true; MyMobile.Battery.BatteryCharger.Charger = initialChargeValue; MyMobile.Battery.BatteryCharger.executeCharge(checkBoxCharge, progressBarCharge); //Thread.Sleep(1000); //Arrange Assert.IsTrue(initialChargeValue < MyMobile.Battery.BatteryCharger.Charger); }