Table tests
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@85 72836036-5685-4462-b002-a69064685172
This commit is contained in:
parent
88292e9304
commit
54fa9085e7
2 changed files with 73 additions and 19 deletions
|
@ -5,27 +5,13 @@ package jrummikub.model;
|
||||||
public class Table extends StoneTray<StoneSet> {
|
public class Table extends StoneTray<StoneSet> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes {@link Stone} from the Table and returns it
|
* Removes {@link Stone} from the Table
|
||||||
*
|
*
|
||||||
* @param position
|
* @param stone
|
||||||
* {@link Position} of the selected {@link Stone}
|
* stone to pick up
|
||||||
*/
|
*/
|
||||||
public Stone pickUpStone(Position position) {
|
public void pickUpStone(Stone stone) {
|
||||||
// TODO implement this method
|
// TODO implement this method
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Removes a part of a {@link StoneSet} from the Table and returns it
|
|
||||||
*
|
|
||||||
* @param from
|
|
||||||
* Start {@link Position} of the range
|
|
||||||
* @param to
|
|
||||||
* End {@link Position} of the range
|
|
||||||
*/
|
|
||||||
public StoneSet pickUpRange(Position from, Position to) {
|
|
||||||
// TODO implement this method
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Tests the Table for rule conflicts by checking all the {@link StoneSet} */
|
/** Tests the Table for rule conflicts by checking all the {@link StoneSet} */
|
||||||
|
@ -33,4 +19,5 @@ public class Table extends StoneTray<StoneSet> {
|
||||||
// TODO implement this method
|
// TODO implement this method
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,72 @@
|
||||||
package jrummikub.model;
|
package jrummikub.model;
|
||||||
|
|
||||||
public class TableTest {
|
import java.util.Arrays;
|
||||||
|
import java.util.Collections;
|
||||||
|
|
||||||
|
import org.junit.*;
|
||||||
|
|
||||||
|
import static jrummikub.model.StoneColor.BLACK;
|
||||||
|
import static jrummikub.model.StoneColor.RED;
|
||||||
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
|
import jrummikub.model.Table;
|
||||||
|
|
||||||
|
public class TableTest {
|
||||||
|
Table testTable;
|
||||||
|
|
||||||
|
@Before
|
||||||
|
public void setup() {
|
||||||
|
testTable = new Table();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testIsValid() {
|
||||||
|
testTable.drop(new StoneSet(Arrays.asList(new Stone(RED), new Stone(BLACK),
|
||||||
|
new Stone(1, BLACK))), new Position(0,0));
|
||||||
|
testTable.drop(new StoneSet(Arrays.asList(new Stone(1, RED), new Stone(2, RED),
|
||||||
|
new Stone(3, RED))), new Position(0,0));
|
||||||
|
assertTrue(testTable.isValid());
|
||||||
|
|
||||||
|
testTable.drop(new StoneSet(Arrays.asList(new Stone(5, RED))), new Position(0,0));
|
||||||
|
assertFalse(testTable.isValid());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testEmptyIsValid() {
|
||||||
|
assertTrue(testTable.isValid());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@SuppressWarnings("unused")
|
||||||
|
public void testPickUpStoneGroup() {
|
||||||
|
Stone targetStone = new Stone(BLACK);
|
||||||
|
testTable.drop(new StoneSet(Arrays.asList(new Stone(RED), targetStone,
|
||||||
|
new Stone(1, BLACK))), new Position(0,0));
|
||||||
|
assertTrue(testTable.isValid());
|
||||||
|
testTable.pickUpStone(targetStone);
|
||||||
|
assertFalse(testTable.isValid());
|
||||||
|
|
||||||
|
int counter = 0;
|
||||||
|
for (Object i : testTable) {
|
||||||
|
counter++;
|
||||||
|
}
|
||||||
|
assertEquals(counter, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@SuppressWarnings("unused")
|
||||||
|
public void testPickUpStoneRun() {
|
||||||
|
Stone targetStone = new Stone(BLACK);
|
||||||
|
testTable.drop(new StoneSet(Arrays.asList(new Stone(1, RED), targetStone,
|
||||||
|
new Stone(3, BLACK))), new Position(0,0));
|
||||||
|
assertTrue(testTable.isValid());
|
||||||
|
testTable.pickUpStone(targetStone);
|
||||||
|
assertFalse(testTable.isValid());
|
||||||
|
|
||||||
|
int counter = 0;
|
||||||
|
for (Object i : testTable) {
|
||||||
|
counter++;
|
||||||
|
}
|
||||||
|
assertEquals(counter, 2);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue