Inheritance Hierarchy
DeltaEngine.Platforms TestWithMocksOrVisually
DeltaEngine.Input.Tests KeyTriggerTests
Namespace: DeltaEngine.Input.Tests
Assembly: DeltaEngine.Input.Tests (in DeltaEngine.Input.Tests.dll) Version: 1.1.1.0 (1.1.1)
Syntax
The KeyTriggerTests type exposes the following members.
Constructors
Name | Description | |
---|---|---|
KeyTriggerTests | Initializes a new instance of the KeyTriggerTests class |
Methods
Name | Description | |
---|---|---|
AdvanceTimeAndUpdateEntities | (Inherited from TestWithMocksOrVisually.) | |
Create | ||
CreateFromAttributes | ||
InitializeResolver | (Inherited from TestWithMocksOrVisually.) | |
PressCursorKeysToShowCircles | ||
PressEscapeToCloseWindow | ||
PressEscapeToCloseWindowViaRegisteredCommands | ||
RegisterMock T | (Inherited from TestWithMocksOrVisually.) | |
Resolve T | (Inherited from TestWithMocksOrVisually.) | |
RunAfterFirstFrame | (Inherited from TestWithMocksOrVisually.) | |
RunTestAndDisposeResolverWhenDone | (Inherited from TestWithMocksOrVisually.) | |
UseMoveDirectlyCommandToMoveCircleAround | ||
ZoomCircleWithPageUpPageDown |
Properties
Name | Description | |
---|---|---|
IsMockResolver | (Inherited from TestWithMocksOrVisually.) |
Examples
[Test] public void PressEscapeToCloseWindow() { new FontText(Font.Default, "Press ESC to close the window", Rectangle.One); new Command(() => Resolve<Window>().CloseAfterFrame()).Add(new KeyTrigger(Key.Escape, State.Pressed)); }
[Test] public void PressEscapeToCloseWindowViaRegisteredCommands() { new FontText(Font.Default, "Press ESC to close the window", Rectangle.One); Command.Register("Exit", new KeyTrigger(Key.Escape, State.Pressed)); new Command("Exit", () => Resolve<Window>().CloseAfterFrame()); }
[Test] public void PressCursorKeysToShowCircles() { var centers = new[] { new Vector2D(0.5f, 0.4f), new Vector2D(0.5f, 0.6f), new Vector2D(0.3f, 0.6f), new Vector2D(0.7f, 0.6f) }; var size = new Size(0.1f, 0.1f); CreateFontTexts(centers, size); AddCirclesAndInputCommands(centers, size); }
[Test, CloseAfterFirstFrame] public void Create() { var trigger = new KeyTrigger(Key.Z, State.Pressed); Assert.AreEqual(Key.Z, trigger.Key); Assert.AreEqual(State.Pressed, trigger.State); }
[Test, CloseAfterFirstFrame] public void CreateFromAttributes() { var trigger = new KeyTrigger(new Dictionary<string, string> { { "Key", "Z" }, { "State", " Pressed" } }); Assert.AreEqual(Key.Z, trigger.Key); Assert.AreEqual(State.Pressed, trigger.State); Assert.Throws<KeyTrigger.CannotCreateKeyTriggerWithoutKey>( () => new KeyTrigger(new Dictionary<string, string>())); } [Test] public void UseMoveDirectlyCommandToMoveCircleAround() { var circle = new Ellipse(Vector2D.Half, 0.25f, 0.25f, Color.Orange); new Command(Command.MoveDirectly, position => circle.DrawArea = circle.DrawArea.Move(position / 24.0f)); //ncrunch: no coverage } [Test] public void ZoomCircleWithPageUpPageDown() { var circle = new Ellipse(Vector2D.Half, 0.25f, 0.25f, Color.Orange); new Command(Command.Zoom, zoom => circle.DrawArea = circle.DrawArea.Increase(new Size(zoom / 24.0f))); //ncrunch: no coverage } }
[Test] public void UseMoveDirectlyCommandToMoveCircleAround() { var circle = new Ellipse(Vector2D.Half, 0.25f, 0.25f, Color.Orange); new Command(Command.MoveDirectly, position => circle.DrawArea = circle.DrawArea.Move(position / 24.0f)); //ncrunch: no coverage }
[Test] public void ZoomCircleWithPageUpPageDown() { var circle = new Ellipse(Vector2D.Half, 0.25f, 0.25f, Color.Orange); new Command(Command.Zoom, zoom => circle.DrawArea = circle.DrawArea.Increase(new Size(zoom / 24.0f))); //ncrunch: no coverage }
See Also