Exemple #1
0
        public void TestPhoneSpeakerPlayCustom()
        {
            PhoneSpeaker phoneSpeaker = new PhoneSpeaker(speakerVolume, new TestOutput(this));

            phoneSpeaker.Play();
            Assert.AreEqual(speakerResultExpectations, Result);
        }
Exemple #2
0
        static void Main(string[] args)
        {
            iPhoneHeadset           iphoneHeadset           = new iPhoneHeadset(new ConsoleOutput());
            SamsungHeadset          samsungHeadset          = new SamsungHeadset(new ConsoleOutput());
            UnofficialiPhoneHeadset unofficialiPhoneHeadset = new UnofficialiPhoneHeadset(new ConsoleOutput());
            PhoneSpeaker            phoneSpeaker            = new PhoneSpeaker(new ConsoleOutput());

            Dictionary <int, IPlayback> playbacks = new Dictionary <int, IPlayback>()
            {
                { 1, iphoneHeadset },
                { 2, samsungHeadset },
                { 3, unofficialiPhoneHeadset },
                { 4, phoneSpeaker },
            };

            PrintMenu();

            int choiseHeadset = GetValidInputNumber();

            Console.WriteLine(playbacks[choiseHeadset].GetType().Name + " playback selected");
            Console.WriteLine($"Set payback to Mobile...");
            Console.WriteLine($"Play sound in Mobile:");

            SimcorpMobile simcorpMobile = new SimcorpMobile(new MultiTouchScreen(), new LithiumIon(), new SingleModule(), new Stereo());

            simcorpMobile.SimcorpMobilePlayback(playbacks[choiseHeadset]);
            simcorpMobile.Play("Song");
        }
        public static IPlayback GetPlaybackType(HeadSetTypes headSetType)
        {
            IPlayback playback = null;
            IOutput   output   = new TextBoxOutput();

            switch (headSetType)
            {
            case HeadSetTypes.iPhoneHeadset:
                playback = new iPhoneHeadset(output);
                break;

            case HeadSetTypes.SamsungHeadset:
                playback = new SamsungHeadset(output);
                break;

            case HeadSetTypes.UnofficialiPhoneHeadset:
                playback = new UnofficialiPhoneHeadset(output);
                break;

            case HeadSetTypes.PhoneSpeaker:
                playback = new PhoneSpeaker(output);
                break;

            default:
                throw new ArgumentException("Invalid playback type");
            }
            return(playback);
        }
Exemple #4
0
        private void button1_Click(object sender, EventArgs e)
        {
            //1st group of radio-buttons (Speaker settings):
            VoiceOutput VoiceOutput = new VoiceOutput();
            ISpeaker    Speaker     = null;

            if (IPhoneHeadset.Checked)
            {
                Speaker = new IphoneHeadset(VoiceOutput, "IphoneX", true);
            }
            else if (SamsungHeadset.Checked)
            {
                Speaker = new SamsungHeadset(VoiceOutput, "SamsungA", true);
            }
            else if (PhoneSpeaker.Checked)
            {
                Speaker = new PhoneSpeaker(VoiceOutput, "model-ABC");
            }
            else
            {
            };

            //there is an option not to select radio button without assertion error
            if (Speaker != null)
            {
                VoiceOutput.DataOutput("Speaker selected");
                Speaker.Play(null);
            }
            else
            {
                VoiceOutput.DataOutput("Speaker is not selected");
            }

            //2nd group of radio-buttons (Screen settings)
            TextOutput TextOutput = new TextOutput();
            ScreenBase Screen     = null;
            string     screenType = null;

            if (MonochromeScreen.Checked)
            {
                Screen     = new MonochromeScreen(TextOutput, 2.0, 200);
                screenType = nameof(MonochromeScreen);
            }
            else if (ColorfulScreen.Checked)
            {
                Screen     = new ColorfulScreen(TextOutput, 7.0, 500, true);
                screenType = nameof(ColorfulScreen);
            }

            //there is an option not to select radio button without assertion error
            if (Screen != null)
            {
                textBox1.Text = "Set screen to Mobile... \n Selected screen is " + screenType;
            }
            else
            {
                textBox1.Text = "Screen is not selected";
            }
        }
Exemple #5
0
        public void TestPhoneSpeakerPlay()
        {
            PhoneSpeaker phoneSpeaker = new PhoneSpeaker(speakerVolume, new TestOutput(this));

            phoneSpeaker.Play();
            string expectations = phoneSpeaker.ToString();

            Assert.AreEqual(expectations, Result);
        }
        public void PlayValidOutputText()
        {
            var output  = new FakeOutput();
            var headset = new PhoneSpeaker(output, 25.0f);
            var Data    = new object();

            headset.Play(Data);

            Assert.AreEqual("PhoneSpeaker sound\n", output.OutputResult);
        }
        public void PhoneSpeaker_IsPlay()
        {
            // Arrange / Act
            IOutput   output   = new OutputMock();
            IPlayback playback = new PhoneSpeaker(output);

            playback.Play(output);

            //Assert
            Assert.IsTrue(output.Output.ToString().Contains("PhoneSpeaker"));
        }
Exemple #8
0
        static void SetPhoneJack(MobilePhoneBase mobile)
        {
            string menuTxt = GetMenuTxt();

            Console.WriteLine(menuTxt);

            while (true)
            {
                try
                {
                    int       userChoice = Int32.Parse(Console.ReadLine());
                    IPlayback playback;
                    var       output = new ConsoleOutput();

                    switch (userChoice)
                    {
                    case 1:
                        playback = new iPhoneHeadset(output);
                        break;

                    case 2:
                        playback = new SamsungHeadset(output);
                        break;

                    case 3:
                        playback = new UnofficialiPhoneHeadset(output);
                        break;

                    case 4:
                        playback = new PhoneSpeaker(output);
                        break;

                    default:
                        throw new ArgumentException(" Your choice is out of scope menu options");
                    }

                    Console.WriteLine(" " + playback.GetType().ToString() + " playback selected");
                    mobile.PlaybackComponent = playback;
                    return;
                }
                catch (ArgumentException ex)
                {
                    Console.WriteLine(ex.Message);
                }
                catch (FormatException)
                {
                    Console.WriteLine(" Use digits for menu options");
                }
                catch
                {
                    throw;
                }
            }
        }
Exemple #9
0
        public void Play_PhoneSpeaker()
        {
            //Arrange
            FakeOutput fakeOutput = new FakeOutput();
            var        expected   = "Do you hear this test sound? Me too\n";
            //Act
            var phoneSpeaker = new PhoneSpeaker(volume: 75, fakeOutput);

            phoneSpeaker.Play("Do you hear this test sound? Me too");
            //Assert
            Assert.AreEqual(expected, fakeOutput.GetOutputAsText());
        }
Exemple #10
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());
            }
        }
Exemple #11
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            FormPlayComponents formPlayComponents = new FormPlayComponents();
            PhoneSpeaker       speaker            = new PhoneSpeaker(1000, new FormOutput(formPlayComponents));
            SamsungHeadset     samsungHeadset     = new SamsungHeadset(300, new FormOutput(formPlayComponents));
            IPhoneHeadset      iPhoneHeadset      = new IPhoneHeadset(350, new FormOutput(formPlayComponents));

            formPlayComponents.Speaker        = speaker;
            formPlayComponents.SamsungHeadset = samsungHeadset;
            formPlayComponents.IPhoneHeadset  = iPhoneHeadset;
            Application.Run(formPlayComponents);
        }
Exemple #12
0
        public void CheckInputAndOutputPhoneSpeakerValue()
        {
            var          output       = new TestableOutput();
            PhoneSpeaker phoneSpeaker = new PhoneSpeaker(output);

            string inputValue = "Madonna Song";

            phoneSpeaker.Play(inputValue);

            string outputValue   = output.WritenLineText;
            string expectedValue = $"{nameof(PhoneSpeaker)} play {inputValue}";

            Assert.AreEqual(expectedValue, outputValue);
        }
Exemple #13
0
        public void PlayTest()
        {
            //-- Arrange
            var output      = new OutputControl();
            var soundDevice = new PhoneSpeaker(output);
            var expected    = "PhoneSpeaker sound\r\n";

            //-- Act;
            soundDevice.Play(new object());
            var actual = output.TextOutput;

            //-- Assert
            Assert.AreEqual(expected, actual);
        }
Exemple #14
0
        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();
            }
        }
        public void Play_PhoneSpeakerSelected_GetPhoneSpeaker()
        {
            // Arrange
            var output       = new FakeOutput();
            var phonespeaker = new PhoneSpeaker(output);

            // Act

            phonespeaker.Play(phonespeaker);
            var result = output.GetText();

            // Assert
            Assert.AreEqual("PhoneSpeaker", result);
        }
Exemple #16
0
        public void PhoneSpeakerPlay()
        {
            // Arrange
            string           actualOutput   = "";
            OutputForTesting VariableOutput = new OutputForTesting(actualOutput);
            PhoneSpeaker     PhoneSpeaker   = new PhoneSpeaker(VariableOutput);

            string expectedOutput = $"{nameof(PhoneSpeaker)} sound";

            // Act
            PhoneSpeaker.Play(new Object());
            actualOutput = VariableOutput.OutputVariable;

            // Assert
            Assert.AreEqual(expectedOutput, actualOutput);
        }
        public void PhoneSpeakerTest()
        {
            var       mobile            = new SimCorpMobilePhone();
            var       consoleOutput     = new ConsoleOutput();
            IPlayback playbackComponent = new PhoneSpeaker(consoleOutput);

            mobile.PlaybackComponent = playbackComponent;
            var expected1 = "PhoneSpeaker playback selected";
            var actual1   = consoleOutput.textTest;

            Assert.AreEqual(expected1, actual1);
            mobile.Play();
            var expected = "PhoneSpeaker sound";
            var actual   = consoleOutput.textTest;

            Assert.AreEqual(expected, actual);
        }
Exemple #18
0
        public static IPlayback CreatePlaybackDevice(PlaybackDeviceType playableDeviceType, IOutput output)
        {
            output.WriteLine("Set playback to Mobile...");
            IPlayback playbackDevice = null;

            switch (playableDeviceType)
            {
            case PlaybackDeviceType.PhoneHeadset:
                playbackDevice = new PhoneHeadset(output);
                output.WriteLine($"{PlaybackDeviceType.PhoneHeadset.ToString()} is selected");
                break;

            case PlaybackDeviceType.PhoneSpeaker:
                playbackDevice = new PhoneSpeaker(output);
                output.WriteLine($"{PlaybackDeviceType.PhoneSpeaker.ToString()} is selected");
                break;

            default:
                throw new ArgumentException("Unexpected index!");
            }
            return(playbackDevice);
        }
Exemple #19
0
        private void SetPlaybackComponentToMobile(WinFormOuput winformOutput)
        {
            IPlayback playbackComponent = null;

            if (radioButton1.Checked)
            {
                playbackComponent = new iPhoneHeadset(winformOutput);
            }
            else if (radioButton2.Checked)
            {
                playbackComponent = new SamsungHeadset(winformOutput);
            }
            else if (radioButton3.Checked)
            {
                playbackComponent = new UnofficialiPhoneHeadset(winformOutput);
            }
            else if (radioButton4.Checked)
            {
                playbackComponent = new PhoneSpeaker(winformOutput);
            }
            mobile.PlaybackComponent = playbackComponent;
            winformOutput.WriteLine("Set playback to Mobile...");
            mobile.Play();
        }
Exemple #20
0
 public SimCorpMobile(ScreenBase screen, BatteryBase battery, PhoneSpeaker speaker)
 {
     this.Screen  = screen;
     this.Battery = battery;
     this.Speaker = speaker;
 }