コード例 #1
0
        public void CommandTestCase()
        {
            var radio = new Radio();
            radio.SwitchOn();
            IVoiceCommand volumeUpCommand = new VolumeUpCommand(radio);
            IVoiceCommand volumeDownCommand = new VolumeDownCommand(radio);

            var window = new ElectricWindow();
            IVoiceCommand windowUpCommand = new WindowUpCommand(window);
            IVoiceCommand windowDownCommand = new WindowDownCommand(window);

            var speechRecognizer = new SpeechRecognizer();
            //control window
            speechRecognizer.SetCommands(windowUpCommand, windowDownCommand);
            //Log
            speechRecognizer.HearDownSpoken();
            speechRecognizer.HearUpSpoken();

            //control radio
            speechRecognizer.SetCommands(volumeUpCommand, volumeDownCommand);
            //Log
            speechRecognizer.HearUpSpoken();
            speechRecognizer.HearUpSpoken();
            speechRecognizer.HearDownSpoken();

            //todo: define tests
        }
コード例 #2
0
 public VolumeUpCommand(Radio radio)
 {
     _radio = radio;
 }
コード例 #3
0
 public VolumeDownCommand(Radio radio)
 {
     _radio = radio;
 }