Test für Stone Set, ohne isValid
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@29 72836036-5685-4462-b002-a69064685172
This commit is contained in:
parent
bc774c639b
commit
5440eaba77
1 changed files with 60 additions and 0 deletions
|
@ -1,6 +1,66 @@
|
||||||
package jrummikub.model;
|
package jrummikub.model;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import jrummikub.util.Pair;
|
||||||
|
import static jrummikub.model.StoneColor.*;
|
||||||
|
|
||||||
|
import org.junit.*;
|
||||||
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
public class StoneSetTest {
|
public class StoneSetTest {
|
||||||
|
|
||||||
|
// invalid Split
|
||||||
|
@Test(expected = AssertionError.class)
|
||||||
|
public void testSplitInvalidLow() {
|
||||||
|
StoneSet testSet = createTestSet();
|
||||||
|
testSet.splitAt(0);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test(expected = AssertionError.class)
|
||||||
|
public void testSplitInvalidHigh() {
|
||||||
|
StoneSet testSet = createTestSet();
|
||||||
|
testSet.splitAt(3);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// valid Split
|
||||||
|
@Test
|
||||||
|
public void testSplitValid() {
|
||||||
|
StoneSet testSet = createTestSet();
|
||||||
|
Pair<StoneSet, StoneSet> newSets = testSet.splitAt(1);
|
||||||
|
// Sets have right size
|
||||||
|
assertEquals(1, newSets.getFirst().size());
|
||||||
|
assertEquals(2, newSets.getSecond().size());
|
||||||
|
// Set have right Stones
|
||||||
|
assertSame(testSet.get(0), newSets.getFirst().get(0));
|
||||||
|
assertSame(testSet.get(1), newSets.getSecond().get(0));
|
||||||
|
assertSame(testSet.get(2), newSets.getSecond().get(1));
|
||||||
|
}
|
||||||
|
|
||||||
|
private StoneSet createTestSet() {
|
||||||
|
List<Stone> stones = new ArrayList<Stone>();
|
||||||
|
stones.add(new Stone(1, BLUE, false));
|
||||||
|
stones.add(new Stone(1, RED, false));
|
||||||
|
stones.add(new Stone(1, BLACK, false));
|
||||||
|
StoneSet testSet = new StoneSet(stones);
|
||||||
|
return testSet;
|
||||||
|
}
|
||||||
|
|
||||||
|
// join
|
||||||
|
@Test
|
||||||
|
public void testJoin() {
|
||||||
|
StoneSet testSet = createTestSet();
|
||||||
|
StoneSet secondSet = new StoneSet(new Stone(2, BLUE, false));
|
||||||
|
StoneSet joinedSet = testSet.join(secondSet);
|
||||||
|
// Sets have right size
|
||||||
|
assertEquals(4, joinedSet.size());
|
||||||
|
// Set have right Stones
|
||||||
|
assertSame(testSet.get(0), joinedSet.get(0));
|
||||||
|
assertSame(testSet.get(1), joinedSet.get(1));
|
||||||
|
assertSame(testSet.get(2), joinedSet.get(2));
|
||||||
|
assertSame(secondSet.get(0), joinedSet.get(3));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue