C# Class Nuclex.Testing.Xna.MockedGraphicsDeviceService

Helper for unit tests requiring a mocked graphics device
This doesn't actually mock the graphics device, but creates a real graphics device on an invisible window. Tests have shown this method to be fast enough for usage in a unit test.
Inheritance: IGraphicsDeviceService
Mostra file Open project: csce3513/Team18 Class Usage Examples

Public Methods

Method Description
CreateDevice ( ) : IDisposable

Creates a new graphics device

Make sure to call DestroyGraphicsDevice() either manually, or by disposing the returned object. A typical usage of this method is shown in the following code.

using(IDisposable keeper = CreateDevice()) { GraphicsDevice.DoSomethingThatCouldFail(); }
DestroyDevice ( ) : void

Destroys the created graphics device again

MockedGraphicsDeviceService ( )

Initializs a new mocked graphics device service

MockedGraphicsDeviceService ( DeviceType deviceType )

Initializs a new mocked graphics device service

MockedGraphicsDeviceService ( DeviceType deviceType, GraphicsProfile graphicsProfile )

Initializs a new mocked graphics device service

ResetDevice ( ) : void

Performs a graphics device reset

Protected Methods

Method Description
OnDeviceCreated ( ) : void

Fires the DeviceCreated event

OnDeviceDisposing ( ) : void

Fires the DeviceDisposing event

OnDeviceReset ( ) : void

Fires the DeviceReset event

OnDeviceResetting ( ) : void

Fires the DeviceResetting event

Private Methods

Method Description
disposeEverything ( ) : void

Shuts down and disposes all resources used by the mocked graphics device service

Method Details

CreateDevice() public method

Creates a new graphics device

Make sure to call DestroyGraphicsDevice() either manually, or by disposing the returned object. A typical usage of this method is shown in the following code.

using(IDisposable keeper = CreateDevice()) { GraphicsDevice.DoSomethingThatCouldFail(); }
public CreateDevice ( ) : IDisposable
return IDisposable

DestroyDevice() public method

Destroys the created graphics device again
public DestroyDevice ( ) : void
return void

MockedGraphicsDeviceService() public method

Initializs a new mocked graphics device service

MockedGraphicsDeviceService() public method

Initializs a new mocked graphics device service
public MockedGraphicsDeviceService ( DeviceType deviceType )
deviceType DeviceType Type of graphics device that will be created

MockedGraphicsDeviceService() public method

Initializs a new mocked graphics device service
public MockedGraphicsDeviceService ( DeviceType deviceType, GraphicsProfile graphicsProfile )
deviceType DeviceType Type of graphics device that will be created
graphicsProfile GraphicsProfile Profile the graphics device will be initialized for

OnDeviceCreated() protected method

Fires the DeviceCreated event
protected OnDeviceCreated ( ) : void
return void

OnDeviceDisposing() protected method

Fires the DeviceDisposing event
protected OnDeviceDisposing ( ) : void
return void

OnDeviceReset() protected method

Fires the DeviceReset event
protected OnDeviceReset ( ) : void
return void

OnDeviceResetting() protected method

Fires the DeviceResetting event
protected OnDeviceResetting ( ) : void
return void

ResetDevice() public method

Performs a graphics device reset
public ResetDevice ( ) : void
return void