SoundDeviceTests ClassDelta Engine Documentation
Inheritance Hierarchy

System Object
  DeltaEngine.Platforms TestWithMocksOrVisually
    DeltaEngine.Multimedia.Tests SoundDeviceTests

Namespace: DeltaEngine.Multimedia.Tests
Assembly: DeltaEngine.Multimedia.Tests (in DeltaEngine.Multimedia.Tests.dll) Version: 1.1.1.0 (1.1.1)
Syntax

public class SoundDeviceTests : TestWithMocksOrVisually

The SoundDeviceTests type exposes the following members.

Constructors

  NameDescription
Public methodSoundDeviceTests
Initializes a new instance of the SoundDeviceTests class
Top
Methods

  NameDescription
Protected methodAdvanceTimeAndUpdateEntities (Inherited from TestWithMocksOrVisually.)
Public methodChangeMusicVolume
Public methodInitializeResolver (Inherited from TestWithMocksOrVisually.)
Public methodPlayAndStopMusic
Public methodPlayMusicAndVideo
Public methodPlayMusicWhileOtherIsPlaying
Protected methodRegisterMock T  (Inherited from TestWithMocksOrVisually.)
Protected methodResolve T  (Inherited from TestWithMocksOrVisually.)
Protected methodRunAfterFirstFrame (Inherited from TestWithMocksOrVisually.)
Public methodRunTestAndDisposeResolverWhenDone (Inherited from TestWithMocksOrVisually.)
Public methodRunWithVideoAndMusic
Public methodTestIfPLayingMusic
Top
Properties

  NameDescription
Protected propertyIsMockResolver (Inherited from TestWithMocksOrVisually.)
Top
Examples

[Test]
public void PlayMusicWhileOtherIsPlaying()
{
    var music1 = ContentLoader.Load<Music>("DefaultMusic");
    var music2 = ContentLoader.Load<Music>("DefaultMusicBackwards");
    music1.Play();
    if (IsMockResolver)
        Assert.False(MockMusic.MusicStopCalled);
    music2.Play();
    if (IsMockResolver)
        Assert.True(MockMusic.MusicStopCalled);
}
[Test]
public void RunWithVideoAndMusic()
{
    var video = ContentLoader.Load<Video>("DefaultVideo");
    var music = ContentLoader.Load<Music>("DefaultMusic");
    video.Play();
    music.Play();
}
[Test]
public void TestIfPLayingMusic()
{
    var video = ContentLoader.Load<Video>("DefaultVideo");
    video.Play();
    Assert.IsTrue(video.IsPlaying());
    Assert.AreEqual(3.33333325f, video.DurationInSeconds);
    Assert.AreEqual(1.0f, video.PositionInSeconds);
}
[Test, CloseAfterFirstFrame]
public void PlayMusicAndVideo()
{
    var device = new MockSoundDevice();
    Assert.IsTrue(device.IsInitialized);
    var music = ContentLoader.Load<Music>("DefaultMusic");
    var video = ContentLoader.Load<Video>("DefaultVideo");
    music.Play();
    video.Play();
    Assert.False(MockMusic.MusicStopCalled);
    Assert.False(MockVideo.VideoStopCalled);
    device.RegisterCurrentMusic(music);
    device.RegisterCurrentVideo(video);
    Assert.IsTrue(device.IsActive);
    Assert.IsTrue(device.IsInitialized);
    device.RapidUpdate();
    device.Dispose();
}
[Test, CloseAfterFirstFrame]
public void PlayAndStopMusic()
{
    var device = new MockSoundDevice();
    Assert.IsFalse(device.IsPauseable);
    Assert.IsTrue(device.IsInitialized);
    var musicTime = ContentLoader.Load<Music>("DefaultMusic");
    musicTime.StreamFinished = () => { };
    musicTime.Play();
    Assert.AreEqual(Settings.Current.MusicVolume, musicTime.Volume);
    device.RegisterCurrentMusic(musicTime);
    musicTime.Stop();
    device.RapidUpdate();
    musicTime.Loop = true;
    musicTime.Stop();
    device.RapidUpdate();
    device.Dispose();
}
[Test, CloseAfterFirstFrame]
public void ChangeMusicVolume()
{
    var device = new MockSoundDevice();
    float defaultMusicVolume = Settings.Current.MusicVolume;
    Assert.IsTrue(device.IsInitialized);
    try
    {
        device.MusicVolume = 1.0f;
        Assert.AreEqual(1.0f, device.MusicVolume);
    }
    finally
    {
        device.MusicVolume = defaultMusicVolume;
    }
    device.RapidUpdate();
    device.Dispose();
}
See Also