public void TestPlay() { ///////////////////////////////////// // 1. Check that Play does not crash Assert.DoesNotThrow(monoInstance.Play, "Call to SoundEffectInstance.Play crashed throwing an exception."); //////////////////////////////////////////////////////////////////// // 2. Check that a second call to Play while playing does not crash Assert.DoesNotThrow(monoInstance.Play, "Second call to SoundEffectInstance.Play while playing crashed throwing an exception."); //////////////////////////////////////////// // 3. Listen that the played sound is valid Utilities.Sleep(1500); ////////////////////////////////////////////////////////////////// // 4. Check that there is no crash when restarting the sound Assert.DoesNotThrow(laugherMono.Play, "Restarting the audio sound after it finishes crashed throwing an exception."); ////////////////////////////////////////////////////////////////////////////////////////////////////// // 5. Check that there is no crash when playing after pausing the sound and that play flow is correct Utilities.Sleep(3000); laugherMono.Pause(); Utilities.Sleep(500); Assert.DoesNotThrow(laugherMono.Play, "Restarting the audio sound after pausing it crashed throwing an exception."); Utilities.Sleep(3000); laugherMono.Stop(); ////////////////////////////////////////////////////////////////////////////////////////////////////// // 6. Check that there is no crash when playing after stopping a sound and that the play flow restart laugherMono.Play(); Utilities.Sleep(3000); laugherMono.Stop(); Utilities.Sleep(500); Assert.DoesNotThrow(laugherMono.Play, "Restarting the audio sound after stopping it crashed throwing an exception."); var countDown = 12000; while (laugherMono.PlayState == SoundPlayState.Playing) { Utilities.Sleep(10); countDown -= 10; if (countDown < 0) { Assert.Fail("laugherMono never stopped playing."); } } //////////////////////////////////////////////////////////////// // 7. Play a stereo file a listen that the played sound is valid stereoInstance.Play(); Utilities.Sleep(2500); ////////////////////////////////////////////////////////////////////////////////// // 8. Check that Playing an Disposed instance throw the 'ObjectDisposedException' var dispInst = monoSoundEffect.CreateInstance(); dispInst.Dispose(); Assert.Throws <ObjectDisposedException>(dispInst.Play, "SoundEffectInstance.Play did not throw the 'ObjectDisposedException' when called from a disposed object."); }
public void TestInvalidationDuringSoundEffectPlay() { oneSound.Play(); // user should unplug and plug back the the headphone here // and check that sound restart without throwing any exceptions. var count = 0; while (count < 1500) { Assert.DoesNotThrow(() => oneSound.Pause()); Assert.DoesNotThrow(() => oneSound.Play()); ++count; Utilities.Sleep(10); } oneSound.Stop(); }