MusicTests ClassDelta Engine Documentation
Inheritance Hierarchy

System Object
  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

public class MusicTests : TestWithMocksOrVisually

The MusicTests type exposes the following members.

Constructors

  NameDescription
Public methodMusicTests
Initializes a new instance of the MusicTests class
Top
Methods

  NameDescription
Protected methodAdvanceTimeAndUpdateEntities (Inherited from TestWithMocksOrVisually.)
Public methodInitializeResolver (Inherited from TestWithMocksOrVisually.)
Public methodPlayDifferentMusicOnClick
Public methodPlayMusic
Public methodPlayMusicNonLooped
Public methodPlayMusicOnClick
Public methodPlayMusicWith10Fps
Public methodPlayMusicWith30Fps
Public methodPlayMusicWith5Fps
Public methodPlayMusicWithHalfVolume
Public methodPlayOggMusic
Public methodPlayWmaMusic
Protected methodRegisterMock T  (Inherited from TestWithMocksOrVisually.)
Protected methodResolve T  (Inherited from TestWithMocksOrVisually.)
Protected methodRunAfterFirstFrame (Inherited from TestWithMocksOrVisually.)
Public methodRunTestAndDisposeResolverWhenDone (Inherited from TestWithMocksOrVisually.)
Public methodShouldThrowIfMusicNotLoadedInDebugModeOrWithDebuggerAttached
Public methodStartAndStopMusic
Public methodTestIfPlayingMusic
Top
Properties

  NameDescription
Protected propertyIsMockResolver (Inherited from TestWithMocksOrVisually.)
Top
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