private void applyButton_Click(object sender, EventArgs e) { OLEDScreen OLEDScreen = new OLEDScreen(768, 1024); LiPoBattery liPoBattery = new LiPoBattery(4100, 3.7, 83); MultiCoreCPU multiCoreCPU = new MultiCoreCPU("SnapDragon", 2.1, 2); MessageStorage messageStorage = new MessageStorage("+380971994730"); SimCorpMobile scmobile = new SimCorpMobile(OLEDScreen, liPoBattery, multiCoreCPU, messageStorage); WinFormsOutput winFormOutput = new WinFormsOutput(this); listBox.Items.Clear(); if (radioButtoniPhone.Checked == true) { scmobile.PlaybackComponent = new iPhoneHeadset(winFormOutput); } else if (radioButtonSamsung.Checked == true) { scmobile.PlaybackComponent = new SamsungHeadset(winFormOutput); } else if (radioButtonNoNameHeadset.Checked == true) { scmobile.PlaybackComponent = new NoNameHeadset(winFormOutput); } else if (radioButtonPhoneSpeaker.Checked == true) { scmobile.PlaybackComponent = new PhoneSpeaker(winFormOutput); } else { listBox.Items.Add("Nothing is selected"); } scmobile.Play("Unknown Artist - His Song"); }
public InterfacesForm() { InitializeComponent(); MyMobile = new SimCorpMobile(); Invoke(new Action(() => { })); }
private void selectButton_Click(object sender, EventArgs e) { bool userHasSelectedComponentType = playbackComponentRadioButton.Checked || chargerRadioButton.Checked || removableStorageRadioButton.Checked || simCardRadioButton.Checked; if (userHasSelectedComponentType) { RichTextBoxOutput RichTextBoxOutput = new RichTextBoxOutput(outputOfSettingAndRunningComponentRichTextBox); TextBoxInput TextBoxInput = new TextBoxInput(chosenComponentTypeIndex); SimCorpMobile simCorpMobile = new SimCorpMobile(RichTextBoxOutput); PhoneComponentsHandler phoneComponentsHandler = new PhoneComponentsHandler(output: RichTextBoxOutput, input: TextBoxInput); if (playbackComponentRadioButton.Checked) { phoneComponentsHandler.GetAndProcessUserSelectionOfPlayback(simCorpMobile); } if (chargerRadioButton.Checked) { phoneComponentsHandler.GetAndProcessUserSelectionOfCharger(simCorpMobile); } if (removableStorageRadioButton.Checked) { phoneComponentsHandler.GetAndProcessUserSelectionOfStorage(simCorpMobile); } if (simCardRadioButton.Checked) { phoneComponentsHandler.GetAndProcessUserSelectionOfSimCard(simCorpMobile); } } }
public void ContactIsAddedAndRemoved() { //Arrange var mobile = new SimCorpMobile(); var contact = new Contact("testname", new List <string> { "111" }); var contact2 = new Contact("testname", new List <string> { "111", "222" }); var contact3 = new Contact("testname2", new List <string> { "111", "222" }); int actual; Contact actual2; var expected = 1; var expected2 = contact3; //Act mobile.InternalStorage.AddContact(contact); mobile.InternalStorage.AddContact(contact); mobile.InternalStorage.AddContact(contact2); mobile.InternalStorage.AddContact(contact3); mobile.InternalStorage.RemoveContact(contact); actual = mobile.InternalStorage.Contacts.Count; actual2 = mobile.InternalStorage.Contacts[0]; //Assert Assert.AreEqual(expected, actual); Assert.AreEqual(expected2, actual2); }
public SMSPhone() { SMSButtonClicked = false; simCorp = new SimCorpMobile(new ListViewOutput(MessageListView)); MsgAdder += AddMsgToTextBox; simCorp.MsgStor.MsgAdded += OnMsgAdded; simCorp.MsgStor.MsgRemoved += OnMsgRemoved; InitializeComponent(); FormatItem defaultItem = new FormatItem("None", StringFormatter.FormatNone); FormatComboBox.Items.Add(defaultItem); FormatComboBox.Items.Add(new FormatItem("Start with DateTime", StringFormatter.FormatStartDateTime)); FormatComboBox.Items.Add(new FormatItem("End with DateTime", StringFormatter.FormatEndDateTime)); FormatComboBox.Items.Add(new FormatItem("Lowercase", StringFormatter.FormatLower)); FormatComboBox.Items.Add(new FormatItem("Uppercase", StringFormatter.FormatUpper)); FormatComboBox.SelectedItem = defaultItem; SenderComboBox.Items.Add(allSenderItem); SenderComboBox.SelectedItem = allSenderItem; OrAndCheckBox.Checked = true; ChargeProgressBar.Value = simCorp.Battery.GetCurrentCharge(); UpdProgBar += OnChargeChanged; BatteryDischargeTask = new Task(() => { Discharge(); }); BatteryDischargeTask.Start(); simCorp.Battery.ChargeChanged += OnChargeLevelChanged; }
public Form1() { InitializeComponent(); Array formats = typeof(FormatStorage.Formats).GetEnumValues(); foreach (var type in formats) { comboBox1.Items.Add(type); } comboBox1.SelectedIndex = (int)FormatStorage.GetFormatStorageInstance().Format; radioButtonOr.Checked = true; dateTimeFrom.CustomFormat = "yyyy/mm/dd hh:mm:ss"; dateTimeTo.CustomFormat = "yyyy/mm/dd hh:mm:ss"; IOutput output = new TextBoxOutput(this); MobilePhone = new SimCorpMobile(output); MobilePhone.SmsStorage.MessagesChanged += UpdateSenders; var mediator = Mediator.GetInstance(); mediator.FormatChanged += FormatStorage.GetFormatStorageInstance().ChangeFormat; MobilePhone.Battery.ChargeChaged += Battery_ChargeChaged; }
static void Main() { /// Lab1 var mobilePhone = new SimCorpMobile(); Console.WriteLine(mobilePhone); /// Lab2 IOutput consoleOutput = new ConsoleOutput(); consoleOutput.WriteLine("Select playback component(select index):"); consoleOutput.WriteLine($"{(int)PlaybackDeviceType.PhoneHeadset} - {PlaybackDeviceType.PhoneHeadset.ToString()}"); consoleOutput.WriteLine($"{(int)PlaybackDeviceType.PhoneSpeaker} - {PlaybackDeviceType.PhoneSpeaker.ToString()}"); var playableDeviceTypeString = Console.ReadLine(); try { var playableDeviceType = CallTryParse(playableDeviceTypeString); var playbackDevice = PlaybackDeviceFactory.CreatePlaybackDevice((PlaybackDeviceType)playableDeviceType, consoleOutput); /// Method Injection /// Inject the dependency into a single method and generally for the use of that method /// It could be useful, where the whole class does not need the dependency, only one method having that dependency /// This is the way is rarely used, but it is what we need in this case mobilePhone.Play(playbackDevice, consoleOutput); } catch (ArgumentException ex) { consoleOutput.WriteLine(ex.Message); } Console.ReadKey(); }
private void buttonApplyPlaybackComp_Click(object sender, EventArgs e) { richTextBoxPlaybackCompInfo.Clear(); string selectedItem = comboBoxSelectPlaybackComp.Text; var playableDeviceType = PlaybackDeviceType.None; if (selectedItem == "PhoneHeadset") { playableDeviceType = PlaybackDeviceType.PhoneHeadset; } else if (selectedItem == "PhoneSpeaker") { playableDeviceType = PlaybackDeviceType.PhoneSpeaker; } IOutput winformOutput = new WinFormOutput(richTextBoxPlaybackCompInfo); if (playableDeviceType != PlaybackDeviceType.None) { var mobilePhone = new SimCorpMobile(); var playbackDevice = PlaybackDeviceFactory.CreatePlaybackDevice(playableDeviceType, winformOutput); mobilePhone.Play(playbackDevice, winformOutput); } else { winformOutput.WriteLine("Select PlaybackDeviceType!"); } }
private static void Main(string[] args) { Mobile.Mobile mobile = new SimCorpMobile(); Console.WriteLine(mobile); Console.ReadKey(); }
static void Main(string[] args) { SimCorpMobile SimCorpMobile = new SimCorpMobile(); Console.WriteLine(SimCorpMobile); Console.ReadKey(); }
private static void Main() { Mobile mobile = new SimCorpMobile(); IOutput output = new WinFormOutput(); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new SelectPlaybackComponent(mobile, output)); }
static void Main(string[] args) { SimCorpMobile MyMobile = new SimCorpMobile(); Console.WriteLine(); Console.WriteLine("_____________________________________________"); MyMobile.ConfigureMobile(); Console.ReadKey(); }
private void InitializePhone() { formInOut = new WinFormInOut(mobileOutBox); simCorpMobile = new SimCorpMobile(formInOut); simCorpMobile.MessageStorage.SMSShow += ShowMessages; simCorpMobile.MessageStorage.SMSNotify += NotifyMessage; simCorpMobile.Battery.ShowCharge += ShowChargeProgress; simCorpMobile?.Battery.Discharge(200); }
private static void Main() { Mobile mobile = new SimCorpMobile(); IOutput output = new WinFormOutput(); string message = "Hello! This is a KSBL's dummy incoming message."; Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new SmsViewer(mobile, output, message)); }
public void FetchNewMsgTest() { SimCorpMobile simCorp = new SimCorpMobile(new FakeOutput()); simCorp.MsgStor.MsgAdded += OnMsgChanged; int expLength = 1; simCorp.GenerateSMS(); Assert.IsTrue(expLength == simCorp.MsgStor.MsgList.Count); }
private SimCorpMobile InitSimCorpMobile() { OLEDScreen OLEDScreen = new OLEDScreen(768, 1024); LiPoBattery liPoBattery = new LiPoBattery(4100, 3.7, 83); MultiCoreCPU multiCoreCPU = new MultiCoreCPU("SnapDragon", 2.1, 2); MessageStorage messageStorage = InitMessageStorage("+380971994730"); SimCorpMobile scmobile = new SimCorpMobile(OLEDScreen, liPoBattery, multiCoreCPU, messageStorage); scmobile.MessageStorage = messageStorage; return(scmobile); }
static void Main(string[] args) { ConsoleOutput ConsoleOutput = new ConsoleOutput(); ConsoleInput ConsoleInput = new ConsoleInput(); SimCorpMobile SimCorpMobile = new SimCorpMobile(ConsoleOutput); PhoneComponentsHandler phoneComponentsHandler = new PhoneComponentsHandler(output: ConsoleOutput, input: ConsoleInput); phoneComponentsHandler.SelectAndSetComponents(SimCorpMobile); Console.ReadKey(); }
public SMSReceiverForm() { InitializeComponent(); comboBox1.SelectedIndex = 0; dateTimePicker1.Value = DateTime.Now.AddDays(-1); dateTimePicker2.Value = DateTime.Now.AddDays(1); MyMobile = new SimCorpMobile(); output = new WFAOutputRichTextBox(richTextBox1); //MyMobile.SMSProvider.SMSReceived += (message) => output.WriteLine(message.ToString()); MyMobile.Storage.SMSAdded += (message) => storageLogTextBox.Text = ($"{message.ToString()} was added to the mobile storage"); MyMobile.Storage.SMSRemoved += (message) => storageLogTextBox.Text = ($"{message.ToString()} was removed from the mobile storage"); }
static void Main(string[] args) { OLEDScreen screen = new OLEDScreen(5, 1920, 1080); LithiumLonBattery battery = new LithiumLonBattery(4000); PhoneSpeaker speaker = new PhoneSpeaker(1000, new ConsoleOutput()); SimCorpMobile simMobile = new SimCorpMobile(screen, battery, speaker); SamsungHeadset samsungHeadsetComp = new SamsungHeadset(300, new ConsoleOutput()); IPhoneHeadset iPhoneHeadsetComp = new IPhoneHeadset(350, new ConsoleOutput()); IAudioController samsungHeadset = (IAudioController)samsungHeadsetComp; IAudioController iPhoneHeadset = (IAudioController)iPhoneHeadsetComp; List <string> playComponentsMenuItems = new List <string>(); playComponentsMenuItems.Add("Phone speaker"); playComponentsMenuItems.Add("Samsung Headset"); playComponentsMenuItems.Add("iPhone Headset"); int userPlaybackChoice = 0; while (true) { while (userPlaybackChoice == 0) { Console.WriteLine(simMobile.ToString()); Console.WriteLine("Please select component (specify index)\n"); foreach (string item in playComponentsMenuItems) { Console.Write(playComponentsMenuItems.IndexOf(item) + 1 + ". "); Console.WriteLine(item); } Console.Write("\nYour choice: "); userPlaybackChoice = CheckUserInput(Console.ReadLine(), playComponentsMenuItems); } switch (userPlaybackChoice) { case 1: simMobile.Play(); break; case 2: simMobile.Play(samsungHeadset); break; case 3: simMobile.Play(iPhoneHeadset); break; } userPlaybackChoice = 0; Console.ReadKey(); Console.Clear(); } }
private void showInfob_Click(object sender, EventArgs e) { SetHeadSetType(); SetChargerType(); if (vCharger != null) { if (vHeadset != null) { var mymobile = new SimCorpMobile(vHeadset, vCharger, vOutputType); mymobile.ToString(); } } }
public void MobilePhoneBatteryZero() { // -- Arrange var mobilePhone = new SimCorpMobile(); mobilePhone.Battery.Charge = -120; var expected = 0; // -- Act var actual = mobilePhone.Battery.Charge; // -- Assert Assert.AreEqual(expected, actual); }
private static void Main() { Mobile mobile = new SimCorpMobile(); IOutput output = new WinFormOutput(); MessageGeneratorCreator messageGeneratorCreator1 = new MessageGeneratorCreatorTask(); MessageGeneratorCreator messageGeneratorCreator2 = new MessageGeneratorCreatorThread(); var messageGenerator = messageGeneratorCreator1.Create(mobile); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new SmsViewer(mobile, output, messageGenerator)); }
private static void Main() { Mobile mobile = new SimCorpMobile(); AddInitialContacts(mobile); CallGeneratorCreator callGeneratorCreator1 = new CallGeneratorCreatorTask(); CallGeneratorCreator callGeneratorCreator2 = new CallGeneratorCreatorThread(); var callGenerator = callGeneratorCreator1.Create(mobile); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new CallViewer(mobile, callGenerator)); }
static void Main(string[] args) { ConsoleOutput outputType = new ConsoleOutput(); HeadsetTypes inputHSType = ReadHeadSet(outputType); ChargerTypes inputChrgType = ReadCharger(outputType); IPlayback headset = HeadsetFactory.GetHeadSet(outputType, inputHSType); ICharger charger = ChargerFactory.GetCharger(inputChrgType); var mymobile = new SimCorpMobile(headset, charger, outputType); Console.WriteLine(mymobile); Console.ReadKey(); }
public SMSPhone() { InitializeComponent(); stringFormatter = new StringFormatter(); Item defaultItem = new Item("None", stringFormatter.FormatNone); FormatComboBox.Items.Add(defaultItem); FormatComboBox.Items.Add(new Item("Start with DateTime", stringFormatter.FormatStartDateTime)); FormatComboBox.Items.Add(new Item("End with DateTime", stringFormatter.FormatEndDateTime)); FormatComboBox.Items.Add(new Item("Lowercase", stringFormatter.FormatLower)); FormatComboBox.Items.Add(new Item("Uppercase", stringFormatter.FormatUpper)); FormatComboBox.SelectedItem = defaultItem; simCorp = new SimCorpMobile(new TextBoxOutput(SMSTextBox)); simCorp.SMSProvider.SMSReceived += OnSMSReceived; }
public void NoPlaybackComponent() { //Arrange IOutput output = new FakeOutput(); var mobile = new SimCorpMobile(); mobile.Output = output; var expect = "Test Output is running"; //Act var actual = mobile.Play(new object()); //Assert Assert.AreEqual(expect, actual); }
public void MessageCantBeRemoved() { //Arrange var mobile = new SimCorpMobile(); var message = new Message("KSBL", "Test message!", new DateTime(1, 1, 1)); int actual; var expected = 0; //Act mobile.InternalStorage.RemoveMessage(message); actual = mobile.InternalStorage.Messages.Count; //Assert Assert.AreEqual(expected, actual); }
public void MessageIsPrinted() { //Arrange var mobile = new SimCorpMobile(); var message = "Test message!"; var expected = "Test message! #1"; string actual; //Act mobile.SmsProvider.PrintMessage(message); actual = mobile.SmsProvider.LastText; //Assert Assert.AreEqual(expected, actual); }
private static void Main() { Mobile mobile = new SimCorpMobile(); mobile.Output = new ConsoleOutput(); mobile.Output.WriteLine(mobile.ToString()); mobile.SelectPlaybackComponent(); mobile.Play(new object()); mobile.SelectChargeComponent(); mobile.Charge(); Console.ReadKey(); }
public void EventIsRaised() { //Arrange var mobile = new SimCorpMobile(); var message = "Test message!"; var expected = "Test message! #1 - Event Raised"; string actual; //Act mobile.SmsProvider.SmsReceived += SmsProvider_SmsReceived; mobile.SmsProvider.PrintMessage(message); actual = Text; //Assert Assert.AreEqual(expected, actual); }