Inheritance Hierarchy
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
The SoundDeviceTests type exposes the following members.
Constructors
Name | Description | |
---|---|---|
SoundDeviceTests | Initializes a new instance of the SoundDeviceTests class |
Methods
Name | Description | |
---|---|---|
AdvanceTimeAndUpdateEntities | (Inherited from TestWithMocksOrVisually.) | |
ChangeMusicVolume | ||
InitializeResolver | (Inherited from TestWithMocksOrVisually.) | |
PlayAndStopMusic | ||
PlayMusicAndVideo | ||
PlayMusicWhileOtherIsPlaying | ||
RegisterMock T | (Inherited from TestWithMocksOrVisually.) | |
Resolve T | (Inherited from TestWithMocksOrVisually.) | |
RunAfterFirstFrame | (Inherited from TestWithMocksOrVisually.) | |
RunTestAndDisposeResolverWhenDone | (Inherited from TestWithMocksOrVisually.) | |
RunWithVideoAndMusic | ||
TestIfPLayingMusic |
Properties
Name | Description | |
---|---|---|
IsMockResolver | (Inherited from TestWithMocksOrVisually.) |
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