Пример #1
0
        public void SetPlaybackDevice()
        {
            Console.Write("Select playback device:\n1 - Phone speakers\n2 - Unofficial headphones\n3 - Samsung headphones\n4 - External speaker\n");
            int selected = Int32.Parse(Console.ReadLine());

            switch (selected)
            {
            case 1:
                PlaybackDevice     = Speaker;
                PlaybackDeviceName = vSpeakerName;
                break;

            case 2:
                PlaybackDevice     = new UnofficialHeadset(new RealSpeaker(0.2), new RealSpeaker(0.2), 50, this.Output);
                PlaybackDeviceName = nameof(UnofficialHeadset);
                break;

            case 3:
                PlaybackDevice     = new SamsungHeadset(new RealSpeaker(0.5), new RealSpeaker(0.5), 20, this.Output);
                PlaybackDeviceName = nameof(SamsungHeadset);
                break;

            case 4:
                PlaybackDevice     = new ExternalSpeaker(new RealSpeaker(10), 20, this.Output);
                PlaybackDeviceName = nameof(ExternalSpeaker);
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
            Console.Write($"{PlaybackDeviceName} playback selected\n Set playback to Mobile...\n");
        }
Пример #2
0
        public void IPlayUnitTest()
        {
            FakeOutput output;
            IPlay      device;
            string     expectedMessage;

            ///MonauralSpeaker Test
            output          = new FakeOutput();
            device          = new MonauralSpeakerSystem(new RealSpeaker(2), 20, output);
            expectedMessage = $"{nameof(MonauralSpeakerSystem)} sound";
            IPlayBaseTest(device, expectedMessage, output);

            ///StereoSpeaker Test
            output          = new FakeOutput();
            device          = new StereoSpeakerSystem(new RealSpeaker(2), new RealSpeaker(2), 20, output);
            expectedMessage = $"{nameof(StereoSpeakerSystem)} sound";
            IPlayBaseTest(device, expectedMessage, output);

            ///UnofficialHeadset Test
            output          = new FakeOutput();
            device          = new UnofficialHeadset(new RealSpeaker(2), new RealSpeaker(2), 20, output);
            expectedMessage = $"{nameof(UnofficialHeadset)} sound";
            IPlayBaseTest(device, expectedMessage, output);

            ///SamsungHeadset Test
            output          = new FakeOutput();
            device          = new SamsungHeadset(new RealSpeaker(2), new RealSpeaker(2), 20, output);
            expectedMessage = $"{nameof(SamsungHeadset)} sound";
            IPlayBaseTest(device, expectedMessage, output);

            ///ExternalSpeaker Test
            output          = new FakeOutput();
            device          = new ExternalSpeaker(new RealSpeaker(2), 20, output);
            expectedMessage = $"{nameof(ExternalSpeaker)} sound";
            IPlayBaseTest(device, expectedMessage, output);
        }