MouseZoomTriggerTests ClassDelta Engine Documentation
Inheritance Hierarchy

System Object
  DeltaEngine.Platforms TestWithMocksOrVisually
    DeltaEngine.Input.Tests MouseZoomTriggerTests

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

public class MouseZoomTriggerTests : TestWithMocksOrVisually

The MouseZoomTriggerTests type exposes the following members.

Constructors

  NameDescription
Public methodMouseZoomTriggerTests
Initializes a new instance of the MouseZoomTriggerTests class
Top
Methods

  NameDescription
Protected methodAdvanceTimeAndUpdateEntities (Inherited from TestWithMocksOrVisually.)
Public methodEmptyMouseZoomTriggerShouldDoNothing
Public methodInitializeResolver (Inherited from TestWithMocksOrVisually.)
Public methodMouseWheelZoomDown
Public methodMouseWheelZoomUp
Public methodMouseWheelZoomUsingCommandName
Protected methodRegisterMock T  (Inherited from TestWithMocksOrVisually.)
Public methodResizeEllipseByZoomTrigger
Protected methodResolve T  (Inherited from TestWithMocksOrVisually.)
Protected methodRunAfterFirstFrame (Inherited from TestWithMocksOrVisually.)
Public methodRunTestAndDisposeResolverWhenDone (Inherited from TestWithMocksOrVisually.)
Public methodUsingParametersForMouseZoomTriggerShouldThrowException
Top
Properties

  NameDescription
Protected propertyIsMockResolver (Inherited from TestWithMocksOrVisually.)
Top
Examples

[Test]
public void ResizeEllipseByZoomTrigger()
{
    var ellipse = new Ellipse(Vector2D.Half, 0.1f, 0.1f, Color.Red);
    new Command(zoomAmount => { ellipse.Radius += zoomAmount * 0.02f; }).Add(
        new MouseZoomTrigger());
}
[Test, CloseAfterFirstFrame]
public void EmptyMouseZoomTriggerShouldDoNothing()
{
    Assert.DoesNotThrow(() => new MouseZoomTrigger(new Dictionary<string, string>()));
}
[Test, CloseAfterFirstFrame]
public void UsingParametersForMouseZoomTriggerShouldThrowException()
{
    Assert.Throws<MouseZoomTrigger.MouseZoomTriggerHasNoParameters>(
        () => new MouseZoomTrigger(new Dictionary<string, string> { { "Bla", "DeltaEngine" } }));
}
[Test, CloseAfterFirstFrame]
public void MouseWheelZoomUp()
{
    var mouse = Resolve<Mouse>() as MockMouse;
    if (mouse == null)
        return; //ncrunch: no coverage 
    bool isZoomed = false;
    new Command((float zoomAmount) => isZoomed = true).Add(new MouseZoomTrigger());
    mouse.ScrollUp();
    AdvanceTimeAndUpdateEntities();
    Assert.IsTrue(isZoomed);
}
[Test, CloseAfterFirstFrame]
public void MouseWheelZoomDown()
{
    var mouse = Resolve<Mouse>() as MockMouse;
    if (mouse == null)
        return; //ncrunch: no coverage 
    bool isZoomed = false;
    new Command((float zoomAmount) => isZoomed = true).Add(new MouseZoomTrigger());
    mouse.ScrollDown();
    AdvanceTimeAndUpdateEntities();
    Assert.IsTrue(isZoomed);
}
[Test, CloseAfterFirstFrame]
public void MouseWheelZoomUsingCommandName()
{
    var mouse = Resolve<Mouse>() as MockMouse;
    if (mouse == null)
        return; //ncrunch: no coverage 
    bool isZoomed = false;
    new Command(Command.Zoom, (float zoomAmount) => isZoomed = true);
    mouse.ScrollUp();
    AdvanceTimeAndUpdateEntities();
    Assert.IsTrue(isZoomed);
}
See Also