예제 #1
0
        public void Play_FileDoesNotExist_Throws()
        {
            var x = AudioFactory.AudioSession(Path.GetRandomFileName());

            Assert.Throws <FileNotFoundException>(() =>
                                                  x.Play());
        }
예제 #2
0
        public void Construct_FileDoesNotExist_DoesNotCreateFile()
        {
            var path = Path.GetRandomFileName();
            var x    = AudioFactory.AudioSession(path);

            Assert.IsFalse(File.Exists(path));
        }
예제 #3
0
 public RecordingSession()
 {
     _tempFile = new TempFile();
     _recorder = AudioFactory.AudioSession(_tempFile.Path);
     _recorder.StartRecording();
     Thread.Sleep(100);
 }
예제 #4
0
        public void StopRecording_NotRecording_Throws()
        {
            var x = AudioFactory.AudioSession(Path.GetRandomFileName());

            Assert.Throws <ApplicationException>(() =>
                                                 x.StopRecordingAndSaveAsWav());
        }
예제 #5
0
 public void Construct_FileDoesExistButEmpty_OK()
 {
     using (var f = new TempFile())
     {
         var x = AudioFactory.AudioSession(f.Path);
     }
 }
예제 #6
0
 public void CanRecord_ConstructWithEmptyFile_True()
 {
     using (var f = new TempFile())
     {
         var x = AudioFactory.AudioSession(f.Path);
         Assert.IsTrue(x.CanRecord);
     }
 }
예제 #7
0
 public void Play_DoesPlay()
 {
     using (var file = TempFile.FromResource(Resources.finished, ".wav")) {
         var x = AudioFactory.AudioSession(file.Path);
         Assert.DoesNotThrow(() => x.Play());
         Assert.DoesNotThrow(() => x.StopPlaying());
     }
 }
예제 #8
0
 public void Play_FileEmpty_Throws()
 {
     using (var f = new TempFile())
     {
         var x = AudioFactory.AudioSession(f.Path);
         Assert.Throws <Exception>(() =>
                                   x.Play());
     }
 }
예제 #9
0
        private ISimpleAudioSession RecordSomething(TempFile f)
        {
            var x = AudioFactory.AudioSession(f.Path);

            x.StartRecording();
            Thread.Sleep(100);
            x.StopRecordingAndSaveAsWav();
            return(x);
        }
예제 #10
0
        public void Record_DoesRecord()
        {
            string fpath = "/tmp/dump.ogg";
            var    x     = AudioFactory.AudioSession(fpath);

            Assert.DoesNotThrow(() => x.StartRecording());
            Assert.IsTrue(x.IsRecording);
            Thread.Sleep(1000);
            Assert.DoesNotThrow(() => x.StopRecordingAndSaveAsWav());
        }
예제 #11
0
 public void IsRecording_WhileRecording_True()
 {
     using (var f = new TempFile())
     {
         var x = AudioFactory.AudioSession(f.Path);
         x.StartRecording();
         Thread.Sleep(100);
         Assert.IsTrue(x.IsRecording);
         x.StopRecordingAndSaveAsWav();
     }
 }
예제 #12
0
        public void RecordThenPlay_SmokeTest()
        {
            using (var f = new TempFile())
            {
                var w = new BackgroundWorker();
                w.DoWork += new DoWorkEventHandler((o, args) => SystemSounds.Exclamation.Play());

                var x = AudioFactory.AudioSession(f.Path);
                x.StartRecording();
                w.RunWorkerAsync();
                Thread.Sleep(1000);
                x.StopRecordingAndSaveAsWav();
                x.Play();
                Thread.Sleep(1000);
                x.StopPlaying();
            }
        }
예제 #13
0
 public void RecordAndStop_FileAlreadyExists_FileReplaced()
 {
     using (var f = new TempFile())
     {
         var old       = File.GetLastWriteTimeUtc(f.Path);
         var oldInfo   = new FileInfo(f.Path);
         var oldLength = oldInfo.Length;
         Assert.AreEqual(0, oldLength);
         var oldTimestamp = oldInfo.LastWriteTimeUtc;
         var x            = AudioFactory.AudioSession(f.Path);
         x.StartRecording();
         Thread.Sleep(1000);
         x.StopRecordingAndSaveAsWav();
         var newInfo = new FileInfo(f.Path);
         Assert.Greater(newInfo.LastWriteTimeUtc, oldTimestamp);
         Assert.Greater(newInfo.Length, oldLength);
     }
 }
예제 #14
0
        public void Play_GiveThaiFileName_ShouldHearTwoSounds()
        {
            using (var d = new TemporaryFolder("palaso media test"))
            {
                var soundPath = d.Combine("ก.wav");
                File.Create(soundPath).Close();
                using (var f = TempFile.TrackExisting(soundPath))
                {
                    var w = new BackgroundWorker();
                    w.DoWork += new DoWorkEventHandler((o, args) => SystemSounds.Exclamation.Play());

                    var x = AudioFactory.AudioSession(f.Path);
                    x.StartRecording();
                    w.RunWorkerAsync();
                    Thread.Sleep(1000);
                    x.StopRecordingAndSaveAsWav();

                    var y = AudioFactory.AudioSession(f.Path);
                    y.Play();
                    Thread.Sleep(1000);
                    y.StopPlaying();
                }
            }
        }
예제 #15
0
        public void CanStop_NonExistantFile_False()
        {
            var x = AudioFactory.AudioSession(Path.GetRandomFileName());

            Assert.IsFalse(x.CanStop);
        }
예제 #16
0
        public void CanRecord_FileDoesNotExist_True()
        {
            var x = AudioFactory.AudioSession(Path.GetRandomFileName());

            Assert.IsTrue(x.CanRecord);
        }
예제 #17
0
 public void Construct_FileDoesNotExist_OK()
 {
     var x = AudioFactory.AudioSession(Path.GetRandomFileName());
 }