Inheritance Hierarchy
DeltaEngine.Platforms TestWithMocksOrVisually
DeltaEngine.Multimedia.Tests MusicTests
Namespace: DeltaEngine.Multimedia.Tests
Assembly: DeltaEngine.Multimedia.Tests (in DeltaEngine.Multimedia.Tests.dll) Version: 1.1.1.0 (1.1.1)
Syntax
The MusicTests type exposes the following members.
Constructors
Name | Description | |
---|---|---|
MusicTests | Initializes a new instance of the MusicTests class |
Methods
Properties
Name | Description | |
---|---|---|
IsMockResolver | (Inherited from TestWithMocksOrVisually.) |
Examples
[Test] public void PlayMusic() { ContentLoader.Load<Music>("DefaultMusic").Play(); }
[Test] public void PlayOggMusic() { ContentLoader.Load<Music>("OggMusic").Play(); }
[Test] public void PlayWmaMusic() { ContentLoader.Load<Music>("WmaMusic").Play(); }
[Test] public void PlayMusicWithHalfVolume() { ContentLoader.Load<Music>("DefaultMusic").Play(0.5f); }
[Test] public void PlayMusicNonLooped() { var music = ContentLoader.Load<Music>("DefaultMusic"); music.Loop = false; music.Play(); }
[Test, CloseAfterFirstFrame] public void TestIfPlayingMusic() { var music = ContentLoader.Load<Music>("DefaultMusic"); music.Play(); Assert.IsTrue(music.IsPlaying()); AssertBetween(4.10f, 4.15f, music.DurationInSeconds); AdvanceTimeAndUpdateEntities(0.5f); AssertBetween(0.25f, 5.0f, music.PositionInSeconds); }
[Test, Ignore] public void PlayMusicOnClick() { new FontText(Font.Default, "Click to Play", Rectangle.One); var music = ContentLoader.Load<Music>("DefaultMusic"); new Command(() => { music.Play(1); }).Add(new MouseButtonTrigger()); }
[Test, Ignore] public void PlayDifferentMusicOnClick() { new FontText(Font.Default, "Click to Play", Rectangle.One); var music = ContentLoader.Load<Music>("DefaultMusic"); var music2 = ContentLoader.Load<Music>("DefaultMusicBackwards"); var musics = new[] { music, music2 }; int index = 0; new Command(() => musics[(index++) % 2].Play(1f)).Add(new MouseButtonTrigger()); }
[Test, Ignore] public void PlayMusicWith5Fps() { var music = ContentLoader.Load<Music>("DefaultMusic"); music.Play(); new SleepEntity(5); }
[Test, Ignore] public void PlayMusicWith10Fps() { var music = ContentLoader.Load<Music>("DefaultMusic"); music.Play(); new SleepEntity(10); }
[Test, Ignore] public void PlayMusicWith30Fps() { var music = ContentLoader.Load<Music>("DefaultMusic"); music.Play(); new SleepEntity(30); }
[Test, Ignore] public void StartAndStopMusic() { var music = ContentLoader.Load<Music>("DefaultMusic"); AssertBetween(4.10f, 4.15f, music.DurationInSeconds); new MusicPlayedOneSecondTester(music); music.Play(); Assert.IsTrue(music.IsPlaying()); }
[Test, Ignore] public void ShouldThrowIfMusicNotLoadedInDebugModeOrWithDebuggerAttached() { if (!Debugger.IsAttached) return; //ncrunch: no coverage start Assert.Throws<ContentLoader.ContentNotFound>( () => ContentLoader.Load<Music>("UnavailableMusic")); }
See Also