Inheritance Hierarchy
DeltaEngine.Platforms TestWithMocksOrVisually
DeltaEngine.Input.Tests MouseDragDropTriggerTests
Namespace: DeltaEngine.Input.Tests
Assembly: DeltaEngine.Input.Tests (in DeltaEngine.Input.Tests.dll) Version: 1.1.1.0 (1.1.1)
Syntax
The MouseDragDropTriggerTests type exposes the following members.
Constructors
Name | Description | |
---|---|---|
MouseDragDropTriggerTests | Initializes a new instance of the MouseDragDropTriggerTests class |
Methods
Name | Description | |
---|---|---|
AdvanceTimeAndUpdateEntities | (Inherited from TestWithMocksOrVisually.) | |
Create | ||
CreateFromAttributes | ||
DragDropCloseToStartPointWillDoNothing | ||
DragDropInsideStartArea | ||
DragDropOutsideStartArea | ||
InitializeResolver | (Inherited from TestWithMocksOrVisually.) | |
RegisterMock T | (Inherited from TestWithMocksOrVisually.) | |
Resolve T | (Inherited from TestWithMocksOrVisually.) | |
RunAfterFirstFrame | (Inherited from TestWithMocksOrVisually.) | |
RunTestAndDisposeResolverWhenDone | (Inherited from TestWithMocksOrVisually.) | |
SetUp |
Properties
Name | Description | |
---|---|---|
IsMockResolver | (Inherited from TestWithMocksOrVisually.) |
Examples
[Test, CloseAfterFirstFrame] public void Create() { var trigger = new MouseDragDropTrigger(Rectangle.One, MouseButton.Right); Assert.AreEqual(Rectangle.One, trigger.StartArea); Assert.AreEqual(MouseButton.Right, trigger.Button); Assert.AreEqual(Vector2D.Unused, trigger.StartDragPosition); }
[Test, CloseAfterFirstFrame] public void CreateFromAttributes() { var trigger = new MouseDragDropTrigger(new Dictionary<string, string> { { "StartArea", "1.1 2.2 3.3 4.4" }, { "Button", "Right" } }); Assert.AreEqual(new Rectangle(1.1f, 2.2f, 3.3f, 4.4f), trigger.StartArea); Assert.AreEqual(MouseButton.Right, trigger.Button); Assert.AreEqual(Vector2D.Unused, trigger.StartDragPosition); Assert.Throws<MouseDragDropTrigger.CannotCreateMouseDragDropTriggerWithoutStartArea>( () => new MouseDragDropTrigger(new Dictionary<string, string>())); } [Test, CloseAfterFirstFrame] public void DragDropOutsideStartArea() { if (mouse == null) return; //ncrunch: no coverage Vector2D startPoint = -Vector2D.One; new Command(position => { startPoint = position; }).Add( new MouseDragDropTrigger(Rectangle.HalfCentered, MouseButton.Left)); SetMouseState(State.Pressing, Vector2D.Zero); SetMouseState(State.Pressed, Vector2D.One); SetMouseState(State.Releasing, Vector2D.One); SetMouseState(State.Released, Vector2D.One); Assert.AreEqual(-Vector2D.One, startPoint); } private void SetMouseState(State state, Vector2D position) { if (mouse == null) return; //ncrunch: no coverage mouse.SetButtonState(MouseButton.Left, state); mouse.SetNativePosition(position); AdvanceTimeAndUpdateEntities(); } [Test, CloseAfterFirstFrame] public void DragDropInsideStartArea() { if (mouse == null) return; //ncrunch: no coverage Vector2D startPoint = -Vector2D.One; new Command(position => { startPoint = position; }).Add( new MouseDragDropTrigger(Rectangle.HalfCentered, MouseButton.Left)); SetMouseState(State.Pressing, Vector2D.Half); SetMouseState(State.Pressed, Vector2D.One); SetMouseState(State.Releasing, Vector2D.One); Assert.AreEqual(Vector2D.Half, startPoint); } [Test, CloseAfterFirstFrame] public void DragDropCloseToStartPointWillDoNothing() { if (mouse == null) return; //ncrunch: no coverage Vector2D startPoint = -Vector2D.One; new Command(position => { startPoint = position; }).Add( new MouseDragDropTrigger(Rectangle.HalfCentered, MouseButton.Left)); SetMouseState(State.Pressing, Vector2D.Half); SetMouseState(State.Pressed, Vector2D.Half); SetMouseState(State.Releasing, Vector2D.Half); Assert.AreEqual(-Vector2D.One, startPoint); } }
[Test, CloseAfterFirstFrame] public void DragDropOutsideStartArea() { if (mouse == null) return; //ncrunch: no coverage Vector2D startPoint = -Vector2D.One; new Command(position => { startPoint = position; }).Add( new MouseDragDropTrigger(Rectangle.HalfCentered, MouseButton.Left)); SetMouseState(State.Pressing, Vector2D.Zero); SetMouseState(State.Pressed, Vector2D.One); SetMouseState(State.Releasing, Vector2D.One); SetMouseState(State.Released, Vector2D.One); Assert.AreEqual(-Vector2D.One, startPoint); }
[Test, CloseAfterFirstFrame] public void DragDropInsideStartArea() { if (mouse == null) return; //ncrunch: no coverage Vector2D startPoint = -Vector2D.One; new Command(position => { startPoint = position; }).Add( new MouseDragDropTrigger(Rectangle.HalfCentered, MouseButton.Left)); SetMouseState(State.Pressing, Vector2D.Half); SetMouseState(State.Pressed, Vector2D.One); SetMouseState(State.Releasing, Vector2D.One); Assert.AreEqual(Vector2D.Half, startPoint); }
[Test, CloseAfterFirstFrame] public void DragDropCloseToStartPointWillDoNothing() { if (mouse == null) return; //ncrunch: no coverage Vector2D startPoint = -Vector2D.One; new Command(position => { startPoint = position; }).Add( new MouseDragDropTrigger(Rectangle.HalfCentered, MouseButton.Left)); SetMouseState(State.Pressing, Vector2D.Half); SetMouseState(State.Pressed, Vector2D.Half); SetMouseState(State.Releasing, Vector2D.Half); Assert.AreEqual(-Vector2D.One, startPoint); }
See Also