Example #1
0
 private void TestIsLoopedLoopImpl(Game game, int loopCount, int loopCountSum)
 {
     if (loopCount == 0)
     {
         // check that the sound loops as it should.
         mainController.IsLooping = true;
         mainController.Play();
     }
     // should hear looped sound
     else if (loopCount == 100)
     {
         Assert.True(PlayState.Playing == mainController.PlayState, "The sound play status was stopped but the sound is supposed to be looped.");
         mainController.Stop();
     }
     // should hear nothing
     else if (loopCount == 150)
     {
         // check that the sound does not loop  as it should.
         mainController.IsLooping = false;
         mainController.Play();
     }
     // should hear not a looped sound
     else if (loopCount == 250)
     {
         Assert.True(PlayState.Stopped == mainController.PlayState, "The sound play status was playing but the sound is supposed to do so.");
         mainController.Stop();
     }
     // should hear not a looped sound
     else if (loopCount == 300)
     {
         // check that setting the isLooped without listener works too
         game.Audio.RemoveListener(listComps[0]);
         game.Audio.RemoveListener(listComps[1]);
         mainController.IsLooping = true;
         game.Audio.AddListener(listComps[0]);
         game.Audio.AddListener(listComps[1]);
         mainController.Play();
     }
     // should hear looped sound
     else if (loopCount == 400)
     {
         Assert.True(PlayState.Playing == mainController.PlayState, "The sound play status was stopped but the sound is supposed to be looped.");
         mainController.Stop();
     }
     // should hear looped sound
     else if (loopCount == 450)
     {
         mainController.Play();
     }
     else if (loopCount == 475)
     {
         // check that IsLooped throws InvalidOperationException when modified while playing.
         Assert.Throws <InvalidOperationException>(() => mainController.IsLooping = true);
         game.Exit();
     }
 }