Ejemplo n.º 1
0
        public void Play_FileDoesNotExist_Throws()
        {
            var x = AudioFactory.AudioSession(Path.GetRandomFileName());

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

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

            Assert.Throws <ApplicationException>(() =>
                                                 x.StopRecordingAndSaveAsWav());
        }
Ejemplo n.º 5
0
 public void Construct_FileDoesExistButEmpty_OK()
 {
     using (var f = new TempFile())
     {
         var x = AudioFactory.AudioSession(f.Path);
     }
 }
Ejemplo n.º 6
0
 public void CanRecord_ConstructWithEmptyFile_True()
 {
     using (var f = new TempFile())
     {
         var x = AudioFactory.AudioSession(f.Path);
         Assert.IsTrue(x.CanRecord);
     }
 }
Ejemplo n.º 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());
     }
 }
Ejemplo n.º 8
0
 public void Play_FileEmpty_Throws()
 {
     using (var f = new TempFile())
     {
         var x = AudioFactory.AudioSession(f.Path);
         Assert.Throws <Exception>(() =>
                                   x.Play());
     }
 }
Ejemplo n.º 9
0
        private ISimpleAudioSession RecordSomething(TempFile f)
        {
            var x = AudioFactory.AudioSession(f.Path);

            x.StartRecording();
            Thread.Sleep(100);
            x.StopRecordingAndSaveAsWav();
            return(x);
        }
Ejemplo n.º 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());
        }
Ejemplo n.º 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();
     }
 }
Ejemplo n.º 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();
            }
        }
Ejemplo n.º 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);
     }
 }
Ejemplo n.º 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();
                }
            }
        }
Ejemplo n.º 15
0
        public void CanStop_NonExistantFile_False()
        {
            var x = AudioFactory.AudioSession(Path.GetRandomFileName());

            Assert.IsFalse(x.CanStop);
        }
Ejemplo n.º 16
0
        public void CanRecord_FileDoesNotExist_True()
        {
            var x = AudioFactory.AudioSession(Path.GetRandomFileName());

            Assert.IsTrue(x.CanRecord);
        }
Ejemplo n.º 17
0
 public void Construct_FileDoesNotExist_OK()
 {
     var x = AudioFactory.AudioSession(Path.GetRandomFileName());
 }