AudioRecorderManager { public boolean record(MediaConfig mediaConfig) throws RecordAudioException { mediaRecorder = ((MainApplication) MainApplication.getContextFromMainApp()).getMediaRecorder(); setupMediaRecorder(mediaConfig); prepareMediaRecorder(); try { mediaRecorder.start(); } catch (IllegalStateException e) { e.printStackTrace(); } isRecording = true; return true; }  boolean record(MediaConfig mediaConfig); void stop(); boolean isRecording();  }
@Test public void shouldSetAudioSourceWhenRecording() throws RecordAudioException { audioRecorderManager.record(mediaConfig); verify(mediaRecorder).setAudioSource(mediaConfig.getAudioSource()); }
@Test public void shouldSetOutputFormatWhenRecording() throws RecordAudioException { audioRecorderManager.record(mediaConfig); verify(mediaRecorder).setOutputFormat(mediaConfig.getOutputFormat()); }
@Test public void shouldSetOutputFileWhenRecording() throws RecordAudioException { audioRecorderManager.record(mediaConfig); verify(mediaRecorder).setOutputFile(anyString()); }
@Test public void shouldSetAudioEncoderWhenRecording() throws RecordAudioException { audioRecorderManager.record(mediaConfig); verify(mediaRecorder).setAudioEncoder(mediaConfig.getAudioEncoder()); }
@Test public void shouldPrepareMediaRecorderWhenRecording() throws RecordAudioException, IOException { audioRecorderManager.record(mediaConfig); verify(mediaRecorder).prepare(); }
@Test public void shouldStartRecordingAudioWhenRecording() throws RecordAudioException { audioRecorderManager.record(mediaConfig); verify(mediaRecorder).start(); }
@Test(expected = RecordAudioException.class) public void shouldThrowRecordAudioExceptionWhenOutputFileIsNull() throws RecordAudioException, IOException { Mockito.doThrow(new IOException()).when(mediaRecorder).prepare(); audioRecorderManager.record(mediaConfig); }