Skip to content
Snippets Groups Projects
Commit c9b308e5 authored by LABOUREL Arnaud's avatar LABOUREL Arnaud
Browse files

Nettoyage des classes

parent 1b0e0488
No related branches found
No related tags found
No related merge requests found
Showing
with 232 additions and 57 deletions
...@@ -2,26 +2,30 @@ package controller; ...@@ -2,26 +2,30 @@ package controller;
import javafx.fxml.FXML; import javafx.fxml.FXML;
import javafx.scene.paint.Color; import javafx.scene.paint.Color;
import model.*; import model.*;
import view.GridTileCanvas; import view.GridCanvas;
import java.util.List; import java.util.List;
import java.util.Random; import java.util.Random;
public class GridController { public class GridController {
public static final Color COLOR_FIRST_NAME_ONE = Color.RED;
public static final Color COLOR_LAST_NAME_ONE = Color.BLUE;
public static final Color COLOR_FIRST_NAME_TWO = Color.GREEN;
public static final Color COLOR_LAST_NAME_TWO = Color.YELLOW;
Random random = new Random(); Random random = new Random();
@FXML @FXML
public GridTileCanvas gridTileCanvas; public GridCanvas gridCanvas;
public void initialize() { public void initialize() {
clearGrid(); clearGrid();
} }
public void fillGrid(TileGenerator tileGenerator) { public void fillGrid(TileGenerator tileGenerator) {
gridTileCanvas.fillGrid(tileGenerator); gridCanvas.fillGrid(tileGenerator);
} }
public void drawGrid() { public void drawGrid() {
gridTileCanvas.update(); gridCanvas.update();
} }
public void clearGrid(){ public void clearGrid(){
...@@ -40,42 +44,61 @@ public class GridController { ...@@ -40,42 +44,61 @@ public class GridController {
} }
@FXML @FXML
public void updateRedUniformTile(){ public void updateFirstNameOneUniformTile(){
updateGrid(new UniformTileGenerator(new InternalSide(Color.RED))); updateGrid(new UniformTileGenerator(COLOR_FIRST_NAME_ONE));
}
@FXML
public void updateFirstNameTwoUniformTile() {
updateGrid(new UniformTileGenerator(COLOR_FIRST_NAME_TWO));
}
@FXML
public void updateLastNameOneUniformTile(){
updateGrid(new UniformTileGenerator(COLOR_LAST_NAME_ONE));
}
@FXML
public void updateLastNameTwoUniformTile() {
updateGrid(new UniformTileGenerator(COLOR_LAST_NAME_TWO));
} }
@FXML @FXML
public void updateRandomColorUniformTile(){ public void updateRandomColorUniformTile(){
updateGrid(new RandomUniformTileGenerator(List.of(Color.RED, Color.BLUE, Color.BLACK), random)); updateGrid(new RandomUniformTileGenerator(List.of(COLOR_FIRST_NAME_ONE, COLOR_LAST_NAME_ONE, COLOR_LAST_NAME_TWO), random));
} }
@FXML @FXML
public void updateRandomTruchetTile(){ public void updateRandomTruchetTile(){
updateGrid(new RandomRotatedTruchetTileGenerator(Color.RED, Color.BLUE, random)); updateGrid(new RandomRotatedTruchetTileGenerator(COLOR_FIRST_NAME_ONE, COLOR_LAST_NAME_ONE, random));
} }
@FXML
public void updateRandomWangTile() { public void updateRandomWangTile() {
updateGrid(new RandomWangTileGenerator(List.of(Color.RED, Color.BLUE, Color.GREEN, Color.YELLOW), random)); updateGrid(new RandomWangTileGenerator(List.of(COLOR_FIRST_NAME_ONE, COLOR_LAST_NAME_ONE, COLOR_FIRST_NAME_TWO, COLOR_LAST_NAME_TWO), random));
} }
@FXML
public void updateRandomConstrainedWangTile() { public void updateRandomConstrainedWangTile() {
updateGrid(new RandomConstrainedWangTileGenerator(List.of(Color.RED, Color.BLUE, Color.GREEN, Color.YELLOW), random)); updateGrid(new RandomConstrainedWangTileGenerator(List.of(COLOR_FIRST_NAME_ONE, COLOR_LAST_NAME_ONE, COLOR_FIRST_NAME_TWO, Color.YELLOW), random));
} }
@FXML
public void updateConstrainedTruchetTile() { public void updateConstrainedTruchetTile() {
updateGrid(new ConstrainedRotatedTruchetTileGenerator(Color.RED, Color.BLUE, random)); updateGrid(new ConstrainedRotatedTruchetTileGenerator(COLOR_FIRST_NAME_ONE, COLOR_LAST_NAME_ONE, random));
} }
@FXML
public void updateRandomWangTileSet() { public void updateRandomWangTileSet() {
updateGrid(new RandomTileSetGenerator(List.of( updateGrid(new RandomTileSetGenerator(List.of(
new WangTile(new Side[]{new InternalSide(Color.RED), new InternalSide(Color.BLUE), new InternalSide(Color.RED), new InternalSide(Color.RED)}), new WangTile(new Side[]{new ColoredSide(COLOR_LAST_NAME_ONE), new ColoredSide(COLOR_FIRST_NAME_ONE), new ColoredSide(COLOR_FIRST_NAME_ONE), new ColoredSide(COLOR_FIRST_NAME_ONE)}),
new WangTile(new Side[]{new InternalSide(Color.RED), new InternalSide(Color.RED), new InternalSide(Color.BLUE), new InternalSide(Color.BLUE)}), new WangTile(new Side[]{new ColoredSide(COLOR_LAST_NAME_TWO), new ColoredSide(COLOR_FIRST_NAME_ONE), new ColoredSide(COLOR_FIRST_NAME_ONE), new ColoredSide(COLOR_FIRST_NAME_ONE)}),
new WangTile(new Side[]{new InternalSide(Color.RED), new InternalSide(Color.GREEN), new InternalSide(Color.GREEN), new InternalSide(Color.GREEN)}), new WangTile(new Side[]{new ColoredSide(COLOR_LAST_NAME_ONE), new ColoredSide(COLOR_FIRST_NAME_ONE), new ColoredSide(COLOR_LAST_NAME_ONE), new ColoredSide(COLOR_FIRST_NAME_TWO)}),
new WangTile(new Side[]{new InternalSide(Color.BLUE), new InternalSide(Color.GREEN), new InternalSide(Color.RED), new InternalSide(Color.BLUE)}), new WangTile(new Side[]{new ColoredSide(COLOR_LAST_NAME_TWO), new ColoredSide(COLOR_FIRST_NAME_ONE), new ColoredSide(COLOR_LAST_NAME_ONE), new ColoredSide(COLOR_FIRST_NAME_TWO)}),
new WangTile(new Side[]{new InternalSide(Color.BLUE), new InternalSide(Color.BLUE), new InternalSide(Color.BLUE), new InternalSide(Color.RED)}), new WangTile(new Side[]{new ColoredSide(COLOR_FIRST_NAME_ONE), new ColoredSide(COLOR_FIRST_NAME_TWO), new ColoredSide(COLOR_LAST_NAME_TWO), new ColoredSide(COLOR_FIRST_NAME_ONE)}),
new WangTile(new Side[]{new InternalSide(Color.BLUE), new InternalSide(Color.RED), new InternalSide(Color.GREEN), new InternalSide(Color.GREEN)}), new WangTile(new Side[]{new ColoredSide(COLOR_FIRST_NAME_TWO), new ColoredSide(COLOR_FIRST_NAME_TWO), new ColoredSide(COLOR_LAST_NAME_TWO), new ColoredSide(COLOR_FIRST_NAME_ONE)}),
new WangTile(new Side[]{new InternalSide(Color.GREEN), new InternalSide(Color.GREEN), new InternalSide(Color.BLUE), new InternalSide(Color.GREEN)}), new WangTile(new Side[]{new ColoredSide(COLOR_FIRST_NAME_ONE), new ColoredSide(COLOR_FIRST_NAME_TWO), new ColoredSide(COLOR_FIRST_NAME_TWO), new ColoredSide(COLOR_FIRST_NAME_TWO)}),
new WangTile(new Side[]{new InternalSide(Color.GREEN), new InternalSide(Color.RED), new InternalSide(Color.RED), new InternalSide(Color.RED)}), new WangTile(new Side[]{new ColoredSide(COLOR_FIRST_NAME_TWO), new ColoredSide(COLOR_FIRST_NAME_TWO), new ColoredSide(COLOR_FIRST_NAME_TWO), new ColoredSide(COLOR_FIRST_NAME_TWO)})), random));
new WangTile(new Side[]{new InternalSide(Color.GREEN), new InternalSide(Color.BLUE), new InternalSide(Color.GREEN), new InternalSide(Color.BLUE)})), random));
} }
} }
...@@ -5,7 +5,6 @@ public class ArrayGrid implements Grid { ...@@ -5,7 +5,6 @@ public class ArrayGrid implements Grid {
private final int numberOfRows; private final int numberOfRows;
private final int numberOfColumns; private final int numberOfColumns;
private final Square[][] squares; private final Square[][] squares;
private final Square outOfGridSquare = new ArraySquare();
/** /**
* Creates a new {@code Grid} instance given the number of rows and columns. * Creates a new {@code Grid} instance given the number of rows and columns.
* *
...@@ -43,7 +42,7 @@ public class ArrayGrid implements Grid { ...@@ -43,7 +42,7 @@ public class ArrayGrid implements Grid {
int rowNeighbor = row + direction.deltaRow; int rowNeighbor = row + direction.deltaRow;
int columnNeighbor = column + direction.deltaColumn; int columnNeighbor = column + direction.deltaColumn;
Square neighboringSquare = Square neighboringSquare =
containsCoordinates(rowNeighbor, columnNeighbor) ? getSquare(rowNeighbor, columnNeighbor) : outOfGridSquare; containsCoordinates(rowNeighbor, columnNeighbor) ? getSquare(rowNeighbor, columnNeighbor) : EmptySquare.EMPTY_SQUARE;
getSquare(row, column).setNeighbor(neighboringSquare, direction); getSquare(row, column).setNeighbor(neighboringSquare, direction);
} }
} }
......
...@@ -4,11 +4,7 @@ import java.util.ArrayList; ...@@ -4,11 +4,7 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
public class ArraySquare implements Square { public class ArraySquare implements Square {
private static final Tile EMPTY_TILE = new UniformTile(EmptySide.EMPTY_SIDE); private Tile tile = EmptyTile.EMPTY_TILE;
private static final Square EMPTY_SQUARE = new ArraySquare();
private Tile tile = EMPTY_TILE;
private final Square[] neighborhood = new Square[CardinalDirection.NUMBER_OF_DIRECTIONS]; private final Square[] neighborhood = new Square[CardinalDirection.NUMBER_OF_DIRECTIONS];
public ArraySquare() { public ArraySquare() {
...@@ -17,7 +13,7 @@ public class ArraySquare implements Square { ...@@ -17,7 +13,7 @@ public class ArraySquare implements Square {
private void setEmptyNeighborhood(){ private void setEmptyNeighborhood(){
for(CardinalDirection direction : CardinalDirection.values()) for(CardinalDirection direction : CardinalDirection.values())
setNeighbor(EMPTY_SQUARE, direction); setNeighbor(EmptySquare.EMPTY_SQUARE, direction);
} }
public Tile getTile(){ public Tile getTile(){
......
...@@ -5,10 +5,10 @@ import javafx.scene.paint.Color; ...@@ -5,10 +5,10 @@ import javafx.scene.paint.Color;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
public class InternalSide implements Side { public class ColoredSide implements Side {
private final Color color; private final Color color;
public InternalSide(Color color) { public ColoredSide(Color color) {
this.color = color; this.color = color;
} }
......
...@@ -11,7 +11,7 @@ public class ConstrainedRotatedTruchetTileGenerator implements TileGenerator{ ...@@ -11,7 +11,7 @@ public class ConstrainedRotatedTruchetTileGenerator implements TileGenerator{
private final List<Tile> rotatedTruchetTiles = new ArrayList<>(); private final List<Tile> rotatedTruchetTiles = new ArrayList<>();
private final Random randomGenerator; private final Random randomGenerator;
public ConstrainedRotatedTruchetTileGenerator(Color color1, Color color2, Random randomGenerator) { public ConstrainedRotatedTruchetTileGenerator(Color color1, Color color2, Random randomGenerator) {
Tile truchetTile = new TruchetTile(new InternalSide(color1), new InternalSide(color2)); Tile truchetTile = new TruchetTile(new ColoredSide(color1), new ColoredSide(color2));
for(Rotation rotation : Rotation.values()){ for(Rotation rotation : Rotation.values()){
rotatedTruchetTiles.add(new RotatedTile(truchetTile, rotation)); rotatedTruchetTiles.add(new RotatedTile(truchetTile, rotation));
} }
......
...@@ -5,7 +5,6 @@ import java.util.Iterator; ...@@ -5,7 +5,6 @@ import java.util.Iterator;
public class EmptyGrid implements Grid{ public class EmptyGrid implements Grid{
private final int numberOfRows; private final int numberOfRows;
private final int numberOfColumns; private final int numberOfColumns;
private static final Square EMPTY_SQUARE = new ArraySquare();
public EmptyGrid(int numberOfRows, int numberOfColumns) { public EmptyGrid(int numberOfRows, int numberOfColumns) {
this.numberOfRows = numberOfRows; this.numberOfRows = numberOfRows;
...@@ -14,7 +13,7 @@ public class EmptyGrid implements Grid{ ...@@ -14,7 +13,7 @@ public class EmptyGrid implements Grid{
@Override @Override
public Square getSquare(int rowIndex, int columnIndex) { public Square getSquare(int rowIndex, int columnIndex) {
return EMPTY_SQUARE; return EmptySquare.EMPTY_SQUARE;
} }
@Override @Override
...@@ -41,7 +40,7 @@ public class EmptyGrid implements Grid{ ...@@ -41,7 +40,7 @@ public class EmptyGrid implements Grid{
@Override @Override
public Square next() { public Square next() {
return EMPTY_SQUARE; return EmptySquare.EMPTY_SQUARE;
} }
}; };
} }
......
package model;
import java.util.List;
public class EmptySquare implements Square{
public static final Square EMPTY_SQUARE = new EmptySquare();
private EmptySquare() {}
@Override
public boolean accept(Tile tile) {
return true;
}
@Override
public void put(Tile tile) {}
@Override
public Tile getTile() {
return EmptyTile.EMPTY_TILE;
}
@Override
public List<Tile> compatibleTiles(List<Tile> tiles) {
return tiles;
}
@Override
public List<Side> compatibleSides(List<Side> sides, CardinalDirection direction) {
return sides;
}
@Override
public Square getNeighbor(CardinalDirection direction) {
return EMPTY_SQUARE;
}
@Override
public void setNeighbor(Square neighbor, CardinalDirection direction) {}
}
package model;
public class EmptyTile implements Tile{
public static Tile EMPTY_TILE = new EmptyTile();
private EmptyTile(){}
@Override
public Side side(CardinalDirection direction) {
return EmptySide.EMPTY_SIDE;
}
}
package model; package model;
public class EmptyTileGenerator implements TileGenerator{ public class EmptyTileGenerator implements TileGenerator{
private Tile emptyTile = new UniformTile(EmptySide.EMPTY_SIDE);
@Override @Override
public Tile nextTile(Square square) { public Tile nextTile(Square square) {
return emptyTile; return EmptyTile.EMPTY_TILE;
} }
} }
...@@ -13,7 +13,7 @@ public class RandomConstrainedWangTileGenerator implements TileGenerator { ...@@ -13,7 +13,7 @@ public class RandomConstrainedWangTileGenerator implements TileGenerator {
public RandomConstrainedWangTileGenerator(List<Color> colors, Random randomGenerator) { public RandomConstrainedWangTileGenerator(List<Color> colors, Random randomGenerator) {
for(Color color : colors) for(Color color : colors)
this.availableSides.add(new InternalSide(color)); this.availableSides.add(new ColoredSide(color));
this.randomGenerator = randomGenerator; this.randomGenerator = randomGenerator;
} }
......
...@@ -11,7 +11,7 @@ public class RandomRotatedTruchetTileGenerator implements TileGenerator{ ...@@ -11,7 +11,7 @@ public class RandomRotatedTruchetTileGenerator implements TileGenerator{
public RandomRotatedTruchetTileGenerator(Color color1, Color color2, Random randomGenerator) { public RandomRotatedTruchetTileGenerator(Color color1, Color color2, Random randomGenerator) {
this.randomGenerator = randomGenerator; this.randomGenerator = randomGenerator;
this.truchetTile = new TruchetTile(new InternalSide(color1), new InternalSide(color2)); this.truchetTile = new TruchetTile(new ColoredSide(color1), new ColoredSide(color2));
} }
@Override @Override
......
...@@ -8,17 +8,17 @@ import java.util.List; ...@@ -8,17 +8,17 @@ import java.util.List;
import java.util.Random; import java.util.Random;
public class RandomUniformTileGenerator implements TileGenerator{ public class RandomUniformTileGenerator implements TileGenerator{
private final List<Side> colors = new ArrayList<>(); private final List<Tile> tiles = new ArrayList<>();
private final Random randomGenerator; private final Random randomGenerator;
public RandomUniformTileGenerator(List<Color> colors, Random randomGenerator) { public RandomUniformTileGenerator(List<Color> colors, Random randomGenerator) {
for(Color color : colors) for(Color color : colors)
this.colors.add(new InternalSide(color)); this.tiles.add(new UniformTile(new ColoredSide(color)));
this.randomGenerator = randomGenerator; this.randomGenerator = randomGenerator;
} }
@Override @Override
public Tile nextTile(Square square) { public Tile nextTile(Square square) {
return new UniformTile(RandomUtil.randomElement(colors, randomGenerator)); return RandomUtil.randomElement(tiles, randomGenerator);
} }
} }
...@@ -13,7 +13,7 @@ public class RandomWangTileGenerator implements TileGenerator{ ...@@ -13,7 +13,7 @@ public class RandomWangTileGenerator implements TileGenerator{
public RandomWangTileGenerator(List<Color> colors, Random randomGenerator) { public RandomWangTileGenerator(List<Color> colors, Random randomGenerator) {
for(Color color : colors) for(Color color : colors)
this.availableSides.add(new InternalSide(color)); this.availableSides.add(new ColoredSide(color));
this.randomGenerator = randomGenerator; this.randomGenerator = randomGenerator;
} }
......
package model; package model;
import javafx.scene.paint.Color;
public class UniformTileGenerator implements TileGenerator{ public class UniformTileGenerator implements TileGenerator{
private final Tile tile; private final Tile tile;
public UniformTileGenerator(Side side) { public UniformTileGenerator(Color color) {
tile = new UniformTile(side); tile = new UniformTile(new ColoredSide(color));
} }
@Override @Override
......
...@@ -7,7 +7,7 @@ import javafx.scene.paint.Color; ...@@ -7,7 +7,7 @@ import javafx.scene.paint.Color;
import model.*; import model.*;
import java.util.List; import java.util.List;
public class GridTileCanvas extends Canvas { public class GridCanvas extends Canvas {
public final double tileWidth; public final double tileWidth;
private final double tileHeight; private final double tileHeight;
...@@ -16,7 +16,7 @@ public class GridTileCanvas extends Canvas { ...@@ -16,7 +16,7 @@ public class GridTileCanvas extends Canvas {
private final Grid tileGrid; private final Grid tileGrid;
private final GraphicsContext graphicsContext; private final GraphicsContext graphicsContext;
public GridTileCanvas(@NamedArg("tileWidth") Double tileWidth, public GridCanvas(@NamedArg("tileWidth") Double tileWidth,
@NamedArg("tileHeight") Double tileHeight, @NamedArg("tileHeight") Double tileHeight,
@NamedArg("numberOfColumns") Integer numberOfColumns, @NamedArg("numberOfColumns") Integer numberOfColumns,
@NamedArg("numberOfRows") Integer numberOfRows) { @NamedArg("numberOfRows") Integer numberOfRows) {
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
<?import javafx.scene.layout.*?> <?import javafx.scene.layout.*?>
<?import view.GridTileCanvas?> <?import view.GridCanvas?>
<?import java.lang.Double?> <?import java.lang.Double?>
<?import java.lang.Integer?> <?import java.lang.Integer?>
<?import javafx.scene.control.MenuBar?> <?import javafx.scene.control.MenuBar?>
...@@ -17,7 +17,13 @@ ...@@ -17,7 +17,13 @@
<Menu mnemonicParsing="false" text="Uniform Tiles"> <Menu mnemonicParsing="false" text="Uniform Tiles">
<MenuItem mnemonicParsing="false" onAction="#updateEmptyUniformTile" text="Empty"> <MenuItem mnemonicParsing="false" onAction="#updateEmptyUniformTile" text="Empty">
</MenuItem> </MenuItem>
<MenuItem mnemonicParsing="false" onAction="#updateRedUniformTile" text="Red"> <MenuItem mnemonicParsing="false" onAction="#updateFirstNameOneUniformTile" text="Firstname 1">
</MenuItem>
<MenuItem mnemonicParsing="false" onAction="#updateLastNameOneUniformTile" text="Lastname 1">
</MenuItem>
<MenuItem mnemonicParsing="false" onAction="#updateFirstNameTwoUniformTile" text="Firstname 2">
</MenuItem>
<MenuItem mnemonicParsing="false" onAction="#updateLastNameTwoUniformTile" text="Lastname 2">
</MenuItem> </MenuItem>
<MenuItem mnemonicParsing="false" onAction="#updateRandomColorUniformTile" text="Random color"> <MenuItem mnemonicParsing="false" onAction="#updateRandomColorUniformTile" text="Random color">
</MenuItem> </MenuItem>
...@@ -37,10 +43,10 @@ ...@@ -37,10 +43,10 @@
</MenuItem> </MenuItem>
</Menu> </Menu>
</MenuBar> </MenuBar>
<GridTileCanvas AnchorPane.topAnchor="40." <GridCanvas AnchorPane.topAnchor="40."
xmlns="http://javafx.com/javafx" xmlns="http://javafx.com/javafx"
xmlns:fx="http://javafx.com/fxml" xmlns:fx="http://javafx.com/fxml"
fx:id="gridTileCanvas"> fx:id="gridCanvas">
<tileWidth> <tileWidth>
<Double fx:value="20"/> <Double fx:value="20"/>
</tileWidth> </tileWidth>
...@@ -53,5 +59,5 @@ ...@@ -53,5 +59,5 @@
<numberOfRows> <numberOfRows>
<Integer fx:value="50"/> <Integer fx:value="50"/>
</numberOfRows> </numberOfRows>
</GridTileCanvas> </GridCanvas>
</AnchorPane> </AnchorPane>
\ No newline at end of file
package model;
import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
public class EmptyGridTest {
@Test
void testGetNumberOfRows(){
assertThat(new EmptyGrid(10,20).getNumberOfRows()).isEqualTo(10);
assertThat(new EmptyGrid(100,200).getNumberOfRows()).isEqualTo(100);
}
@Test
void testGetNumberOfColumns(){
assertThat(new EmptyGrid(10,20).getNumberOfColumns()).isEqualTo(20);
assertThat(new EmptyGrid(100,200).getNumberOfColumns()).isEqualTo(200);
}
@Test
void testGetSquare(){
Grid emptyGrid = new EmptyGrid(100,20);
assertThat(emptyGrid.getSquare(0, 0)).isEqualTo(EmptySquare.EMPTY_SQUARE);
assertThat(emptyGrid.getSquare(10, 9)).isEqualTo(EmptySquare.EMPTY_SQUARE);
assertThat(emptyGrid.getSquare(99, 19)).isEqualTo(EmptySquare.EMPTY_SQUARE);
}
}
package model;
import javafx.scene.paint.Color;
import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
import java.util.List;
public class EmptySideTest {
@Test
void testCompatibleSides(){
List<Side> sides = List.of(EmptySide.EMPTY_SIDE);
assertThat(EmptySide.EMPTY_SIDE.compatibleSides(sides)).containsExactly(EmptySide.EMPTY_SIDE);
}
@Test
void testColor(){
assertThat(EmptySide.EMPTY_SIDE.color()).isEqualTo(Color.WHITE);
}
@Test
void testAccept(){
assertThat(EmptySide.EMPTY_SIDE.accept(EmptySide.EMPTY_SIDE)).isTrue();
}
}
package model;
import org.junit.jupiter.api.Test;
import java.util.List;
import static org.assertj.core.api.Assertions.assertThat;
public class EmptySquareTest {
@Test
void testAccept(){
assertThat(EmptySquare.EMPTY_SQUARE.accept(EmptyTile.EMPTY_TILE)).isTrue();
}
@Test
void testGetTile(){
assertThat(EmptySquare.EMPTY_SQUARE.getTile()).isEqualTo(EmptyTile.EMPTY_TILE);
}
@Test
void testCompatibleTiles(){
assertThat(EmptySquare.EMPTY_SQUARE.compatibleTiles(List.of(EmptyTile.EMPTY_TILE))).containsExactly(EmptyTile.EMPTY_TILE);
}
@Test
void testCompatibleSides(){
assertThat(EmptySquare.EMPTY_SQUARE.compatibleSides(List.of(EmptySide.EMPTY_SIDE), CardinalDirection.NORTH)).containsExactly(EmptySide.EMPTY_SIDE);
}
@Test
void testGetNeighbor(){
assertThat(EmptySquare.EMPTY_SQUARE.getNeighbor(CardinalDirection.NORTH)).isEqualTo(EmptySquare.EMPTY_SQUARE);
}
}
package model;
import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
public class EmptyTileGeneratorTest {
@Test
void testNextTile(){
TileGenerator tileGenerator = new EmptyTileGenerator();
assertThat(tileGenerator.nextTile(EmptySquare.EMPTY_SQUARE)).isEqualTo(EmptyTile.EMPTY_TILE);
assertThat(tileGenerator.nextTile(EmptySquare.EMPTY_SQUARE)).isEqualTo(EmptyTile.EMPTY_TILE);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment