-
Notifications
You must be signed in to change notification settings - Fork 5
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
16 changed files
with
452 additions
and
17 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
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,27 @@ | ||
package pl.uj.io.cuteanimals.model; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
|
||
class ArcherTest { | ||
private Archer m; | ||
|
||
@BeforeEach | ||
void setUp() { | ||
m = new Archer(); | ||
} | ||
|
||
@Test | ||
void testToString() { | ||
assertThat(m.toString()).isEqualTo("Archer"); | ||
} | ||
|
||
@Test | ||
void getAbilities() { | ||
assertThat(m.getAbilities()).isNotEmpty(); | ||
assertThat(m.getAbilities()).containsKeys("focus"); | ||
assertThat(m.getAbilities()).containsKeys("bullseye"); | ||
} | ||
} |
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
80 changes: 80 additions & 0 deletions
80
src/test/java/pl/uj/io/cuteanimals/model/DefaultLocationTest.java
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,80 @@ | ||
package pl.uj.io.cuteanimals.model; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
import static org.mockito.Mockito.verify; | ||
|
||
import java.util.List; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.ExtendWith; | ||
import org.mockito.Mock; | ||
import org.mockito.junit.jupiter.MockitoExtension; | ||
import pl.uj.io.cuteanimals.model.entity.Attributes; | ||
import pl.uj.io.cuteanimals.model.entity.Item; | ||
import pl.uj.io.cuteanimals.model.interfaces.IAction; | ||
import pl.uj.io.cuteanimals.model.interfaces.IPlayer; | ||
|
||
@ExtendWith(MockitoExtension.class) | ||
class DefaultLocationTest { | ||
@Mock IAction ac; | ||
@Mock IPlayer p; | ||
private DefaultLocation loc; | ||
|
||
@BeforeEach | ||
void setUp() { | ||
loc = new DefaultLocation(); | ||
loc.setDescription("desc"); | ||
} | ||
|
||
@Test | ||
void getDescription() { | ||
assertThat(loc.getDescription()).isEqualTo("desc"); | ||
} | ||
|
||
@Test | ||
void getAvailableActions() {} | ||
|
||
@Test | ||
void setAvailableActions() {} | ||
|
||
@Test | ||
void getNPCs() { | ||
var claudius = | ||
new NPC( | ||
null, | ||
null, | ||
"Claudius", | ||
List.of("If I were you I would run as fast as I can...")); | ||
var mag1 = new NPC(null, null, "Herschel", List.of("Please... help us!")); | ||
|
||
loc.setNPCs(List.of(claudius, mag1)); | ||
assertThat(loc.getNPCs()).contains(mag1); | ||
assertThat(loc.getNPCs()).contains(claudius); | ||
} | ||
|
||
@Test | ||
void getItems() { | ||
var armor = new Item(1, "pach", "aaa", 1, new Attributes(1, 1, 1, 1, 1, 1), ItemType.ARMOR); | ||
var armor2 = | ||
new Item(2, "pach", "aaa", 1, new Attributes(1, 1, 1, 1, 1, 1), ItemType.ARMOR); | ||
var bp = new Backpack(); | ||
bp.putItem(armor2); | ||
bp.putItem(armor); | ||
loc.setItems(bp); | ||
assertThat(loc.getItems().getItems()).contains(armor); | ||
assertThat(loc.getItems().getItems()).contains(armor2); | ||
} | ||
|
||
@Test | ||
void actionOnEnter() { | ||
loc.setActionOnEnter(ac); | ||
assertThat(loc.getActionOnEnter()).isEqualTo(ac); | ||
loc.onEnter(p); | ||
verify(ac).execute(p); | ||
} | ||
|
||
@Test | ||
void nullActionOnEnter() { | ||
assertThat(loc.onEnter(p).getMessage()).isBlank(); | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
src/test/java/pl/uj/io/cuteanimals/model/MagicianTest.java
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,27 @@ | ||
package pl.uj.io.cuteanimals.model; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
|
||
class MagicianTest { | ||
private Magician m; | ||
|
||
@BeforeEach | ||
void setUp() { | ||
m = new Magician(); | ||
} | ||
|
||
@Test | ||
void testToString() { | ||
assertThat(m.toString()).isEqualTo("Magician"); | ||
} | ||
|
||
@Test | ||
void getAbilities() { | ||
assertThat(m.getAbilities()).isNotEmpty(); | ||
assertThat(m.getAbilities()).containsKeys("focus"); | ||
assertThat(m.getAbilities()).containsKeys("heal"); | ||
} | ||
} |
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,27 @@ | ||
package pl.uj.io.cuteanimals.model; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
import pl.uj.io.cuteanimals.model.entity.Attributes; | ||
|
||
// Sweet 100% coverage | ||
class MonsterTest { | ||
private Monster mob; | ||
|
||
@BeforeEach | ||
void setUp() { | ||
mob = new Monster("mob", new Attributes(1, 1, 1, 1, 1, 1)); | ||
} | ||
|
||
@Test | ||
void getEquipment() { | ||
assertThat(mob.getEquipment()).isNotNull(); | ||
} | ||
|
||
@Test | ||
void getArmor() { | ||
assertThat(mob.getArmor()).isNull(); | ||
} | ||
} |
Oops, something went wrong.