-
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
Showing
6 changed files
with
196 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package oz222am_hangman; | ||
|
||
import org.junit.jupiter.api.AfterAll; | ||
import org.junit.jupiter.api.BeforeAll; | ||
import org.mockito.Mock; | ||
import oz222am_hangman.Models.Words.Word; | ||
|
||
|
||
public class HangmanTest { | ||
@BeforeAll | ||
public void setUp() throws Exception { | ||
} | ||
|
||
@AfterAll | ||
public void tearDown() throws Exception { | ||
|
||
} | ||
|
||
@Mock | ||
Word word; | ||
|
||
} |
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 |
---|---|---|
@@ -0,0 +1,68 @@ | ||
package oz222am_hangman.Models.Games; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import oz222am_hangman.Models.Words.Word; | ||
|
||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
|
||
public class GameTest { | ||
|
||
|
||
@Test | ||
public void shouldReturnTrue() throws Exception { | ||
String input = "abc"; | ||
var word = new Word(); | ||
word.setValue(input); | ||
|
||
var game = new Game(word); | ||
assertTrue(game.verify('c')); | ||
} | ||
|
||
@Test | ||
public void shouldDisplayCharacter() throws Exception { | ||
String input = "abc"; | ||
var word = new Word(); | ||
word.setValue(input); | ||
|
||
var game = new Game(word); | ||
game.verify('c'); | ||
|
||
assertEquals(game.display(), "_ _ c "); | ||
} | ||
|
||
|
||
@Test | ||
public void sholudNotSolved() throws Exception { | ||
String input = "abc"; | ||
var word = new Word(); | ||
word.setValue(input); | ||
|
||
var game = new Game(word); | ||
game.verify('c'); | ||
assertFalse(game.isSolved()); | ||
} | ||
|
||
@Test | ||
public void sholudReturnZero() throws Exception { | ||
String input = "abc"; | ||
var word = new Word(); | ||
word.setValue(input); | ||
|
||
var game = new Game(word); | ||
game.verify('c'); | ||
assertEquals(game.getFailedTries(), 0); | ||
} | ||
|
||
@Test | ||
public void sholudReturnTotalOne() throws Exception { | ||
String input = "abc"; | ||
var word = new Word(); | ||
word.setValue(input); | ||
|
||
var game = new Game(word); | ||
game.verify('c'); | ||
assertEquals(game.getTotalTires(), 1); | ||
} | ||
|
||
} |
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 |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package oz222am_hangman.Models.Players; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertThrows; | ||
|
||
|
||
public class PlayerTest { | ||
private Player sut = new Player(); | ||
|
||
@Test | ||
public void shouldSetValue() throws Exception { | ||
String input = "otherName"; | ||
|
||
sut.setName(input); | ||
assertEquals(sut.getName(), input); | ||
} | ||
|
||
|
||
@Test | ||
public void shouldThrowException() { | ||
String input = ""; | ||
|
||
assertThrows(Exception.class, | ||
()-> sut.setName(input)); | ||
} | ||
|
||
|
||
@Test | ||
public void shouldReturnValue() throws Exception { | ||
String input = "otherName"; | ||
String expected = input; | ||
sut.setName(input); //setup sut | ||
|
||
assertEquals(sut.getName(), expected); | ||
} | ||
|
||
@Test | ||
public void shouldReturnString() throws Exception { | ||
String input = "otherName"; | ||
String expected = "[0] Player: " + input; | ||
sut.setName(input); //setup sut | ||
|
||
|
||
assertEquals(sut.toString(), expected); | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package oz222am_hangman.Models.Words; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertThrows; | ||
|
||
|
||
public class WordTest { | ||
private Word sut = new Word(); | ||
|
||
@Test | ||
public void shouldSetValue() throws Exception { | ||
String input = "otherName"; | ||
|
||
sut.setValue(input); | ||
assertEquals(sut.getValue(), input); | ||
} | ||
|
||
|
||
@Test | ||
public void shouldThrowException() { | ||
String input = ""; | ||
|
||
assertThrows(Exception.class, | ||
()-> sut.setValue(input)); | ||
} | ||
|
||
|
||
@Test | ||
public void shouldReturnValue() throws Exception { | ||
String input = "otherName"; | ||
String expected = input; | ||
sut.setValue(input); //setup sut | ||
|
||
assertEquals(sut.getValue(), expected); | ||
} | ||
|
||
@Test | ||
public void shouldReturnString() throws Exception { | ||
String input = "otherName"; | ||
String expected = "[0] Word: " + input; | ||
sut.setValue(input); //setup sut | ||
|
||
|
||
assertEquals(sut.toString(), expected); | ||
} | ||
} |
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 |
---|---|---|
|
@@ -2,3 +2,4 @@ jaja | |
kaka | ||
software | ||
university | ||
jkjkjkl] |