예제 #1
0
 public void MoveCamera()
 {
     mockMouse = Resolve <Mouse>() as MockMouse;
     AdvanceTimeAndUpdateEntities();
     mockMouse.SetButtonState(MouseButton.Left, State.Pressed);
     AdvanceTimeAndUpdateEntities();
     Assert.IsTrue(musicPreviewer.music.IsPlaying());
 }
예제 #2
0
 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);
 }
예제 #3
0
        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);
        }
예제 #4
0
        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);
        }
예제 #5
0
        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);
        }
예제 #6
0
        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();
 }
예제 #8
0
 private void ClickAtPosition(MockMouse mouse, Vector2D position)
 {
     SetStateAndPosition(mouse, State.Pressing, position);
     SetStateAndPosition(mouse, State.Releasing, position);
 }
예제 #9
0
 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));
 }