public void MoveCamera() { mockMouse = Resolve <Mouse>() as MockMouse; AdvanceTimeAndUpdateEntities(); mockMouse.SetButtonState(MouseButton.Left, State.Pressed); AdvanceTimeAndUpdateEntities(); Assert.IsTrue(musicPreviewer.music.IsPlaying()); }
public void ZoomCamera() { mockMouse = Resolve <Mouse>() as MockMouse; AdvanceTimeAndUpdateEntities(); Assert.AreEqual(new Vector2D(0.5f, 0.5f), spriteSheetPreviewer.currentDisplayAnimation.Center); mockMouse.SetButtonState(MouseButton.Middle, State.Pressed); mockMouse.SetNativePosition(new Vector2D(1f, 1f)); AdvanceTimeAndUpdateEntities(); Assert.AreEqual(0.5f, spriteSheetPreviewer.currentDisplayAnimation.DrawArea.Width); }
public void MouseZoomWillZoomCamera() { if (!IsMockResolver) { return; //ncrunch: no coverage } MockMouse mouse = (MockMouse)Resolve <Mouse>(); var originalZoom = gameCamera.ZoomLevel; mouse.ScrollUp(); AdvanceTimeAndUpdateEntities(); Assert.AreNotEqual(originalZoom, gameCamera.ZoomLevel); }
public void CannotZoomFurtherThanMinimumValue() { if (!IsMockResolver) { return; //ncrunch: no coverage } MockMouse mouse = (MockMouse)Resolve <Mouse>(); gameCamera.ZoomLevel = gameCamera.MinZoom; var originalZoom = gameCamera.ZoomLevel; mouse.ScrollDown(); AdvanceTimeAndUpdateEntities(); Assert.AreEqual(originalZoom, gameCamera.ZoomLevel); }
public void CameraCannotMoveOutOfItsRectangle() { gameCamera.AllowedMovementRect = Rectangle.Zero; var originalPosition = gameCamera.Position; if (!IsMockResolver) { return; //ncrunch: no coverage } MockMouse mouse = (MockMouse)Resolve <Mouse>(); mouse.SetNativePosition(ScreenSpace.Current.Viewport.TopLeft + new Vector2D(0.1f, 0.1f)); mouse.SetButtonState(MouseButton.Middle, State.Pressing); AdvanceTimeAndUpdateEntities(); mouse.SetNativePosition(ScreenSpace.Current.Viewport.TopRight + new Vector2D(-0.1f, 0.1f)); mouse.SetButtonState(MouseButton.Middle, State.Pressed); AdvanceTimeAndUpdateEntities(); Assert.AreEqual(originalPosition, gameCamera.Position); }
public void MouseDragWillDragCamera() { if (!IsMockResolver) { return; //ncrunch: no coverage } MockMouse mouse = (MockMouse)Resolve <Mouse>(); var originalPosition = gameCamera.Position; bool dragInvoked = false; new Command("ViewPanning", () => dragInvoked = true); mouse.SetNativePosition(ScreenSpace.Current.Viewport.TopLeft + new Vector2D(0.1f, 0.1f)); mouse.SetButtonState(MouseButton.Middle, State.Pressing); AdvanceTimeAndUpdateEntities(); mouse.SetNativePosition(ScreenSpace.Current.Viewport.TopRight + new Vector2D(-0.1f, 0.1f)); mouse.SetButtonState(MouseButton.Middle, State.Pressed); AdvanceTimeAndUpdateEntities(); Assert.IsTrue(dragInvoked); Assert.AreNotEqual(originalPosition, gameCamera.Position); Assert.AreEqual(135.0f, (gameCamera.Position - originalPosition).Angle(Vector3D.UnitY)); }
private void AdvanceMouseTick(MockMouse mouse, State state, Vector2D position) { mouse.SetButtonState(MouseButton.Left, state); mouse.SetNativePosition(position); AdvanceTimeAndUpdateEntities(); }
private void ClickAtPosition(MockMouse mouse, Vector2D position) { SetStateAndPosition(mouse, State.Pressing, position); SetStateAndPosition(mouse, State.Releasing, position); }
private void DragMouse(MockMouse mouse, float x, float y) { SetStateAndPosition(mouse, State.Pressing, new Vector2D(x, y)); SetStateAndPosition(mouse, State.Pressed, new Vector2D(x - 0.1f, y)); SetStateAndPosition(mouse, State.Releasing, new Vector2D(x - 0.2f, y)); }