DeviceTests ClassDelta Engine Documentation
Inheritance Hierarchy

System Object
  DeltaEngine.Platforms TestWithMocksOrVisually
    DeltaEngine.Graphics.Tests DeviceTests

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

public class DeviceTests : TestWithMocksOrVisually

The DeviceTests type exposes the following members.

Constructors

  NameDescription
Public methodDeviceTests
Initializes a new instance of the DeviceTests class
Top
Methods

  NameDescription
Protected methodAdvanceTimeAndUpdateEntities (Inherited from TestWithMocksOrVisually.)
Public methodDrawRedBackground
Public methodInitializeResolver (Inherited from TestWithMocksOrVisually.)
Public methodOnSet3DModeActionIsCalledWhenSetting3DMode
Protected methodRegisterMock T  (Inherited from TestWithMocksOrVisually.)
Protected methodResolve T  (Inherited from TestWithMocksOrVisually.)
Protected methodRunAfterFirstFrame (Inherited from TestWithMocksOrVisually.)
Public methodRunTestAndDisposeResolverWhenDone (Inherited from TestWithMocksOrVisually.)
Public methodSetFullscreenCallsDevicesOnFullscreenChanged
Public methodSetFullscreenModeToJustWindowWithoutDeviceAndShowRedBackground
Public methodSizeChanged
Public methodToggleFullscreenModeWithSpaceKey
Top
Properties

  NameDescription
Protected propertyIsMockResolver (Inherited from TestWithMocksOrVisually.)
Top
Examples

[Test, ApproveFirstFrameScreenshot]
public void DrawRedBackground()
{
    Resolve<Window>().BackgroundColor = Color.Red;
}
[Test]
public void SizeChanged()
{
    Resolve<Window>().ViewportPixelSize = new Size(200, 100);
    Assert.AreEqual(new Size(200, 100), Resolve<Window>().ViewportPixelSize);
}
[Test, ApproveFirstFrameScreenshot]
public void SetFullscreenModeToJustWindowWithoutDeviceAndShowRedBackground()
{
    var settings = Resolve<Settings>();
    settings.StartInFullscreen = true; // does not mean we really go fullscreen without device!
    Resolve<Window>().BackgroundColor = Color.Red;
    settings.StartInFullscreen = false;
}
[Test]
public void SetFullscreenCallsDevicesOnFullscreenChanged()
{
    var device = Resolve<Device>() as MockDevice;
    if (device == null)
        return; //ncrunch: no coverage
    Assert.IsFalse(device.OnFullscreenChangedCalled);
    var window = Resolve<Window>();
    window.SetFullscreen(Size.One);
    Assert.IsTrue(device.OnFullscreenChangedCalled);
}
[Test]
public void ToggleFullscreenModeWithSpaceKey()
{
    var window = Resolve<Window>();
    window.BackgroundColor = Color.Red;
    bool fullscreen = false;
    var screenSize = GetScreenSize();
    //ncrunch: no coverage start 
    new Command(() =>
    {
        if (fullscreen)
            window.SetWindowed();
        else
            window.SetFullscreen(screenSize);
        fullscreen = !fullscreen;
    }).Add(new KeyTrigger(Key.Space));
    //ncrunch: no coverage end
}
[Test]
public void OnSet3DModeActionIsCalledWhenSetting3DMode()
{
    var device = Resolve<Device>() as MockDevice;
    if (device == null)
        return; //ncrunch: no coverage
    Assert.IsFalse(device.OnSet3DModeCalled);
    device.Set3DMode();
    Assert.IsTrue(device.OnSet3DModeCalled);
}
See Also