CursorPositionTranslaterTests ClassDelta Engine Documentation
Inheritance Hierarchy

System Object
  DeltaEngine.Platforms TestWithMocksOrVisually
    DeltaEngine.Input.Windows.Tests CursorPositionTranslaterTests

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

public class CursorPositionTranslaterTests : TestWithMocksOrVisually

The CursorPositionTranslaterTests type exposes the following members.

Constructors

  NameDescription
Public methodCursorPositionTranslaterTests
Initializes a new instance of the CursorPositionTranslaterTests class
Top
Methods

  NameDescription
Protected methodAdvanceTimeAndUpdateEntities (Inherited from TestWithMocksOrVisually.)
Public methodConvertPixelFromScreenPositionAndBack
Public methodGetClientPositionOnScreen
Public methodGetReturnsWhatWasSet
Public methodInitializeResolver (Inherited from TestWithMocksOrVisually.)
Protected methodRegisterMock T  (Inherited from TestWithMocksOrVisually.)
Protected methodResolve T  (Inherited from TestWithMocksOrVisually.)
Protected methodRunAfterFirstFrame (Inherited from TestWithMocksOrVisually.)
Public methodRunTestAndDisposeResolverWhenDone (Inherited from TestWithMocksOrVisually.)
Top
Properties

  NameDescription
Protected propertyIsMockResolver (Inherited from TestWithMocksOrVisually.)
Top
Examples

[Test, CloseAfterFirstFrame]
public void GetClientPositionOnScreen()
{
    var window = Resolve<Window>();
    var translator = new CursorPositionTranslater(window);
    var outsidePosition = Resolve<ScreenSpace>().FromPixelSpace(new Vector2D(-10, -10));
    var screenPos = translator.ToScreenPositionFromScreenSpace(outsidePosition);
    Assert.IsTrue(screenPos.X < window.PixelPosition.X || screenPos.Y < window.PixelPosition.Y);
    Assert.AreEqual(outsidePosition, translator.FromScreenPositionToScreenSpace(screenPos));
}
[Test, CloseAfterFirstFrame]
public void ConvertPixelFromScreenPositionAndBack()
{
    var positionTranslator = new CursorPositionTranslater(Resolve<Window>());
    var topLeftPixel = Vector2D.Zero;
    var outside = positionTranslator.FromScreenPositionToScreenSpace(topLeftPixel);
    Assert.AreEqual(topLeftPixel, positionTranslator.ToScreenPositionFromScreenSpace(outside));
}
[Test, CloseAfterFirstFrame, Ignore] // This moves the mouse every time NCrunch runs! 
public void GetReturnsWhatWasSet()
{
    var positionTranslator = new CursorPositionTranslater(Resolve<Window>());
    var setPoint = new Vector2D(0.1f, 0.2f);
    positionTranslator.SetCursorPosition(setPoint);
    var getPoint = positionTranslator.GetCursorPosition();
    Assert.AreEqual(setPoint.X, getPoint.X, 0.1f);
    Assert.AreEqual(setPoint.Y, getPoint.Y, 0.1f);
}
See Also