-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Roel van Dun
committed
Oct 20, 2015
1 parent
a2a1244
commit ca6a4e7
Showing
6 changed files
with
105 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,41 @@ | ||
package nl.roelvandun.setgame; | ||
|
||
import org.junit.Before; | ||
import org.junit.Test; | ||
|
||
import static org.hamcrest.core.IsEqual.equalTo; | ||
import static org.junit.Assert.assertThat; | ||
|
||
public class CardTest { | ||
|
||
private Card card; | ||
|
||
@Test | ||
public void equalsWorks() throws Exception { | ||
Card card = new Card(Card.Color.GREEN, Card.Amount.THREE, Card.Filling.FULL, Card.Form.DIAMONDS); | ||
Card identicalCard = new Card(Card.Color.GREEN, Card.Amount.THREE, Card.Filling.FULL, Card.Form.DIAMONDS); | ||
|
||
assertThat(card, equalTo(identicalCard)); | ||
} | ||
|
||
@Before | ||
public void setUp() throws Exception { | ||
card = new Card(Card.Color.GREEN, Card.Amount.THREE, Card.Filling.FULL, Card.Form.DIAMONDS); | ||
} | ||
|
||
@Test | ||
public void hashCodeWorks() throws Exception { | ||
Card card = new Card(Card.Color.GREEN, Card.Amount.THREE, Card.Filling.FULL, Card.Form.DIAMONDS); | ||
Card identicalCard = new Card(Card.Color.GREEN, Card.Amount.THREE, Card.Filling.FULL, Card.Form.DIAMONDS); | ||
|
||
assertThat(card.hashCode(), equalTo(identicalCard.hashCode())); | ||
} | ||
|
||
@Test | ||
public void toStringWorks() throws Exception { | ||
Card redNoneOneOvalCard = new Card(Card.Color.RED, Card.Amount.ONE, Card.Filling.NONE, Card.Form.OVAL); | ||
Card purpleHalfTwoWaveCard = new Card(Card.Color.PURPLE, Card.Amount.TWO, Card.Filling.HALF, Card.Form.WAVE); | ||
|
||
assertThat(redNoneOneOvalCard.toString(), equalTo("red \t [ ] \t O")); | ||
assertThat(purpleHalfTwoWaveCard.toString(), equalTo("purple \t [\\] \t ~~")); | ||
assertThat(card.toString(), equalTo("green \t [*] \t <><><>")); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters