VideoTests ClassDelta Engine Documentation
Test video playback. Xna video loading won't work from ReSharper, use Program.cs instead. View code on GitHub
Inheritance Hierarchy

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

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

public class VideoTests : TestWithMocksOrVisually

The VideoTests type exposes the following members.

Constructors

  NameDescription
Public methodVideoTests
Initializes a new instance of the VideoTests class
Top
Methods

  NameDescription
Protected methodAdvanceTimeAndUpdateEntities (Inherited from TestWithMocksOrVisually.)
Public methodCheckDurationAndPosition
Public methodExpectExceptionIfVideoIsNotAvailable
Public methodInitializeResolver (Inherited from TestWithMocksOrVisually.)
Public methodLoadTestVideo
Public methodPlayAndStop
Public methodPlayAndStopWithEntitiesRunner
Public methodPlayVideo
Public methodPlayVideoOnClick
Public methodPlayVideoWhileOtherIsPlaying
Protected methodRegisterMock T  (Inherited from TestWithMocksOrVisually.)
Protected methodResolve T  (Inherited from TestWithMocksOrVisually.)
Protected methodRunAfterFirstFrame (Inherited from TestWithMocksOrVisually.)
Public methodRunTestAndDisposeResolverWhenDone (Inherited from TestWithMocksOrVisually.)
Public methodStartAndStopVideo
Top
Properties

  NameDescription
Protected propertyIsMockResolver (Inherited from TestWithMocksOrVisually.)
Top
Examples

[Test]
public void ExpectExceptionIfVideoIsNotAvailable()
{
    Assert.Throws<Video.VideoNotFoundOrAccessible>(
        () => ContentLoader.Load<Video>("NonExistingVideo"));
}
[Test]
public void PlayVideo()
{
    testVideo.Play();
}
[Test]
public void PlayVideoOnClick()
{
    new FontText(Font.Default, "Click to Play", Rectangle.One);
    new Command(() => { testVideo.Play(); }).Add(new MouseButtonTrigger());
}
[Test]
public void PlayAndStop()
{
    testVideo.Stop();
    Assert.IsFalse(testVideo.IsPlaying());
    testVideo.Play();
    Assert.IsTrue(testVideo.IsPlaying());
}
[Test]
public void PlayAndStopWithEntitiesRunner()
{
    int startedNumberOfEntities = EntitiesRunner.Current.NumberOfEntities;
    Assert.AreEqual(startedNumberOfEntities, EntitiesRunner.Current.NumberOfEntities);
    testVideo.Stop();
    Assert.AreEqual(startedNumberOfEntities, EntitiesRunner.Current.NumberOfEntities);
    testVideo.Play();
    Assert.AreEqual(startedNumberOfEntities + 1, EntitiesRunner.Current.NumberOfEntities);
    testVideo.Stop();
    Assert.AreEqual(startedNumberOfEntities, EntitiesRunner.Current.NumberOfEntities);
}
[Test]
public void PlayVideoWhileOtherIsPlaying()
{
    var otherTestVideo = ContentLoader.Load<Video>("DefaultVideo");
    testVideo.Play();
    Assert.False(MockVideo.VideoStopCalled);
    otherTestVideo.Play();
    Assert.False(MockVideo.VideoStopCalled);
}
[Test]
public void CheckDurationAndPosition()
{
    testVideo.Update();
    Assert.AreEqual(3.791f, testVideo.DurationInSeconds, 0.5f);
    Assert.AreEqual(1.0f, testVideo.PositionInSeconds);
}
[Test]
public void StartAndStopVideo()
{
    Assert.AreEqual(3.791f, testVideo.DurationInSeconds, 0.5f);
    var videoTester = new VideoPlayedOneSecondTester(testVideo);
    Assert.IsTrue(videoTester.IsPauseable);
    testVideo.Play();
}
See Also