@Test public void hasNoNodeInPositiveX() { StandardBoard mockedBoard = Mockito.mock(StandardBoard.class); StandardNode mockedSourceNode = Mockito.mock(StandardNode.class); Mockito.when(mockedSourceNode.getOccupantPlayerId()).thenReturn("thisPlayer"); Mockito.when(mockedSourceNode.getXCoordinate()).thenReturn(1); Mockito.when(mockedSourceNode.getYCoordinate()).thenReturn(1); StandardNode mockedOtherNode = Mockito.mock(StandardNode.class); Mockito.when(mockedOtherNode.getOccupantPlayerId()).thenReturn("otherPlayer"); Mockito.when(mockedOtherNode.isMarked()).thenReturn(true); Mockito.when(mockedBoard.getNode(2, 1)).thenReturn(mockedOtherNode); Mockito.when(mockedBoard.getNode(3, 1)).thenReturn(null); List<Node> result = this.callNodesInLineMethod(mockedBoard, mockedSourceNode, 1, 0); Assert.assertEquals(0, result.size()); }
@Test public void hasOneNodeInNegativeXPositiveY() { StandardBoard mockedBoard = Mockito.mock(StandardBoard.class); StandardNode mockedSourceNode = Mockito.mock(StandardNode.class); Mockito.when(mockedSourceNode.getOccupantPlayerId()).thenReturn("thisPlayer"); Mockito.when(mockedSourceNode.getXCoordinate()).thenReturn(3); Mockito.when(mockedSourceNode.getYCoordinate()).thenReturn(3); StandardNode mockedOtherNode = Mockito.mock(StandardNode.class); Mockito.when(mockedOtherNode.getOccupantPlayerId()).thenReturn("otherPlayer"); Mockito.when(mockedOtherNode.isMarked()).thenReturn(true); Mockito.when(mockedBoard.getNode(2, 4)).thenReturn(mockedOtherNode); StandardNode mockedPlayerNode = Mockito.mock(StandardNode.class); Mockito.when(mockedPlayerNode.getOccupantPlayerId()).thenReturn("thisPlayer"); Mockito.when(mockedPlayerNode.isMarked()).thenReturn(true); Mockito.when(mockedBoard.getNode(1, 5)).thenReturn(mockedPlayerNode); List<Node> result = this.callNodesInLineMethod(mockedBoard, mockedSourceNode, -1, 1); Assert.assertEquals(1, result.size()); Assert.assertEquals("otherPlayer", result.get(0).getOccupantPlayerId()); }