public void ShouldNotMoveWindowIfItHasNoNeighbour() { //given var size = new Size(960, 540); var gridElement = new Dimensions(new Point(0, 0), size); var config = new GridConfig { GridElements = new[] { gridElement } }; var grid = _gridFactory.FromConfig(config); var dummyWindow = new DummyWindowRepresentation { Dimensions = new Dimensions(new Point(1, 2), new Size(55, 55)) }; A.CallTo(() => _windowManager.GetActiveWindow()).Returns(dummyWindow); //when grid.MoveActiveWindow(GridDirections.Left); //then Assert.That(dummyWindow.Dimensions, Is.EqualTo(gridElement)); //when grid.MoveActiveWindow(GridDirections.Right); //then Assert.That(dummyWindow.Dimensions, Is.EqualTo(gridElement)); //when grid.MoveActiveWindow(GridDirections.Down); //then Assert.That(dummyWindow.Dimensions, Is.EqualTo(gridElement)); //when grid.MoveActiveWindow(GridDirections.Left); //then Assert.That(dummyWindow.Dimensions, Is.EqualTo(gridElement)); //when grid.MoveActiveWindow(GridDirections.Up); //then Assert.That(dummyWindow.Dimensions, Is.EqualTo(gridElement)); }
public void ShouldChooseLeftWindowIfMultipleGridElementsFoundInTheSameDistanceWhenMovingVertically(GridDirections direction, int expectedX, int expectedY) { //given var windowExactlyInTheMiddle = new DummyWindowRepresentation { Dimensions = _theMiddle }; A.CallTo(() => _windowManager.GetActiveWindow()).Returns(windowExactlyInTheMiddle); var expectedDimensions = new Dimensions(new Point(expectedX, expectedY), _quarterSize); //when _quarterGrid.MoveActiveWindow(direction); //then Assert.That(windowExactlyInTheMiddle.Dimensions, Is.EqualTo(expectedDimensions)); }
public void ShouldMoveWindowToTheGridElementWithOriginClosestToTheWindowInTheDirectionWeWantToMoveIt(GridDirections direction, int windowX, int windowY, int expectedX, int expectedY) { //given var window = new DummyWindowRepresentation { Dimensions = new Dimensions(new Point(windowX, windowY), _quarterSize) }; A.CallTo(() => _windowManager.GetActiveWindow()).Returns(window); var expectedDimensions = new Dimensions(new Point(expectedX, expectedY), _quarterSize); //when _quarterGrid.MoveActiveWindow(direction); //then Assert.That(window.Dimensions, Is.EqualTo(expectedDimensions)); }
public void ShouldCorrectlyBuildGridWithPartialNeighbourMap() { //given var size = new Size(960, 540); var topLeft = new Dimensions(new Point(0, 0), size); var topRight = new Dimensions(new Point(960, 0), size); var bottomLeft = new Dimensions(new Point(0, 540), size); var bottomRight = new Dimensions(new Point(960, 540), size); var config = new GridConfig { GridElements = new[] { topLeft, topRight, bottomLeft, bottomRight }, NeighbourMap = new[] { new NeighboursMap { Id = 0, Neighbours = new [] { 2, 1, 2, 1 } } } }; var dummyWindow = new DummyWindowRepresentation { Dimensions = new Dimensions(new Point(0, 0), new Size(55, 55)) }; A.CallTo(() => _windowManager.GetActiveWindow()).Returns(dummyWindow); var gridFactory = _gridFactory; var grid = gridFactory.FromConfig(config); //when grid.MoveActiveWindow(GridDirections.Left); //then Assert.That(dummyWindow.Dimensions, Is.EqualTo(topLeft)); //when grid.MoveActiveWindow(GridDirections.Right); //then Assert.That(dummyWindow.Dimensions, Is.EqualTo(topRight)); }
public void ShouldCallRespectiveGridElementsWhenMovingWindowAlreadyOnGrid(GridDirections moveDirection, int expectedX, int expectedY) { //given var windowInLeftTopQuarter = new DummyWindowRepresentation() { Dimensions = _leftTop.Dimensions }; A.CallTo(() => _windowManager.GetActiveWindow()).Returns(windowInLeftTopQuarter); var expectedDimensions = new Dimensions(new Point(expectedX, expectedY), _quarterSize); //when _quarterGrid.MoveActiveWindow(moveDirection); //then Assert.That(windowInLeftTopQuarter.Dimensions, Is.EqualTo(expectedDimensions)); }