Exemplo n.º 1
0
        private void ApplyButton_Click(object sender, EventArgs e)
        {
            var output      = new LabelOutput(OutputLabel);
            var smsStorage  = new MessageStorage();
            var mobilePhone = new MobilePhone(Model.Iphone10, output, smsStorage);

            output.WriteLine(mobilePhone.GetDescription());

            var choice = -1;

            if (HeadPhonesRadioButton.Checked)
            {
                choice = 1;
            }
            if (SpeakersRadioButton.Checked)
            {
                choice = 2;
            }
            if (PhoneSpeakerRadioButton.Checked)
            {
                choice = 3;
            }

            IPlayback audioDevice = null;

            if (choice == -1)
            {
                return;
            }

            if (choice == 1)
            {
                audioDevice = new Headphones(output);
            }
            else if (choice == 2)
            {
                audioDevice = new Speakers(false, output);
            }
            else if (choice == 3)
            {
                audioDevice = new PhoneSpeaker(output);
            }
            else
            {
                output.Write("No Valid channel selected");
            }

            if (audioDevice != null)
            {
                mobilePhone.InsertEquipmentInJackStick(audioDevice);
                mobilePhone.AudioInJackStik.Play(new object());
            }
        }
Exemplo n.º 2
0
        public void CreatePhone_Headphones_OutputValidate()
        {
            //arrange
            var output     = new FakeOutput();
            var smsStorage = new MessageStorage();
            var mobile     = new MobilePhone(Model.Iphone8, output, smsStorage);

            //act
            mobile.InsertEquipmentInJackStick(new Headphones(output));
            mobile.AudioInJackStik.Play(new object());

            //assert
            string outputFromMobile = output.WriteLineText;

            Assert.AreEqual(outputFromMobile, "Plays on the " + typeof(Headphones));
        }