GlobalTimeTests ClassDelta Engine Documentation
Inheritance Hierarchy

System Object
  DeltaEngine.Tests.Core GlobalTimeTests

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

public class GlobalTimeTests

The GlobalTimeTests type exposes the following members.

Constructors

  NameDescription
Public methodGlobalTimeTests
Initializes a new instance of the GlobalTimeTests class
Top
Methods

  NameDescription
Public methodCalculateFps
Public methodCalculateFpsWithStopwatch
Public methodFpsShouldBeSixty
Public methodGetSecondsSinceStartToday
Public methodInitializeMockTime
Public methodRunTime
Public methodRunTimeWithStopwatch
Top
Examples

[Test]
public void RunTime()
{
    time.Update();
    Assert.LessOrEqual(time.Milliseconds, 50);
}
[Test]
public void RunTimeWithStopwatch()
{
    time = new StopwatchTime();
    time.Update();
    Assert.IsTrue(time.Milliseconds < 2, "Milliseconds=" + time.Milliseconds);
}
[Test]
public void CalculateFps()
{
    do
        time.Update();
    while (time.Milliseconds <= 1000);
    Assert.IsTrue(Math.Abs(time.Fps - 20) <= 1, "Fps=" + time.Fps);
}
[Test]
public void GetSecondsSinceStartToday()
{
    Assert.LessOrEqual(time.GetSecondsSinceStartToday(), 1.0f / 20.0f);
    time.Update();
    Assert.AreNotEqual(0.0f, time.GetSecondsSinceStartToday());
}
[Test]
public void FpsShouldBeSixty()
{
    Assert.AreEqual(60, GlobalTime.Current.Fps);
}
[Test, Ignore]
public void CalculateFpsWithStopwatch()
{
    time = new StopwatchTime();
    const int TargetFps = 30;
    do
    {
        Thread.Sleep(1000 / TargetFps);
        time.Update();
    } while (time.Milliseconds < 1000);
    Assert.IsTrue(Math.Abs(time.Fps - TargetFps) <= 5, "Fps=" + time.Fps);
}
See Also