-
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
380 additions
and
24 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
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
50 changes: 50 additions & 0 deletions
50
src/test/java/pl/uj/io/cuteanimals/model/BackpackTest.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,50 @@ | ||
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; | ||
import pl.uj.io.cuteanimals.model.entity.Item; | ||
|
||
class BackpackTest { | ||
private Backpack bp; | ||
|
||
@BeforeEach | ||
void setUp() { | ||
bp = new Backpack(); | ||
} | ||
|
||
@Test | ||
void putAndRemoveItem() { | ||
var weapon = | ||
new Item(1, "pach", "aaa", 1, new Attributes(1, 1, 1, 1, 1, 1), ItemType.WEAPON); | ||
var heavy = | ||
new Item(1, "pach", "aaa", 40, new Attributes(1, 1, 1, 1, 1, 1), ItemType.ARMOR); | ||
|
||
assertThat(bp.putItem(weapon)); | ||
assertThat(bp.putItem(heavy)); | ||
assertThat(bp.getItems().size()).isEqualTo(2); | ||
assertThat(bp.getItems()).contains(heavy); | ||
assertThat(bp.getItems()).contains(weapon); | ||
assertThat(bp.removeItem(weapon)); | ||
assertThat(bp.getItems().size()).isEqualTo(1); | ||
assertThat(bp.removeItem(heavy)); | ||
assertThat(bp.getItems()).isEmpty(); | ||
} | ||
|
||
@Test | ||
void showItemsDoesntCrash() { | ||
assertThat(bp.showItems()).isNotBlank(); | ||
assertThat( | ||
bp.putItem( | ||
new Item( | ||
1, | ||
"pach", | ||
"aaa", | ||
1, | ||
new Attributes(1, 1, 1, 1, 1, 1), | ||
ItemType.WEAPON))); | ||
assertThat(bp.showItems()).isNotBlank(); | ||
} | ||
} |
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,34 @@ | ||
package pl.uj.io.cuteanimals.model; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
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; | ||
|
||
@ExtendWith(MockitoExtension.class) | ||
class NPCTest { | ||
@Mock private ArmorBackpack abp; | ||
@Mock private Backpack bp; | ||
private NPC npc; | ||
|
||
@BeforeEach | ||
void setUp() { | ||
npc = new NPC(abp, bp, "test", List.of("t1", "t2", "t3")); | ||
} | ||
|
||
@Test | ||
void getQuote() { | ||
assertThat(npc.getQuote()).isEqualTo("t1"); | ||
assertThat(npc.getQuote()).isEqualTo("t2"); | ||
assertThat(npc.getQuote()).isEqualTo("t3"); | ||
assertThat(npc.getQuote()).isEqualTo("This character can't tell you anything interesting"); | ||
assertThat(npc.getQuote()).isEqualTo("This character can't tell you anything interesting"); | ||
assertThat(npc.getQuote()).isEqualTo("This character can't tell you anything interesting"); | ||
assertThat(npc.getQuote()).isEqualTo("This character can't tell you anything interesting"); | ||
assertThat(npc.getQuote()).isEqualTo("This character can't tell you anything interesting"); | ||
} | ||
} |
58 changes: 58 additions & 0 deletions
58
src/test/java/pl/uj/io/cuteanimals/model/PlayerBackpackTest.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,58 @@ | ||
package pl.uj.io.cuteanimals.model; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
import static org.mockito.Mockito.when; | ||
|
||
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.IAttributes; | ||
|
||
@ExtendWith(MockitoExtension.class) | ||
class PlayerBackpackTest { | ||
@Mock private IAttributes attrs; | ||
private PlayerBackpack bp; | ||
|
||
@BeforeEach | ||
void setUp() { | ||
bp = new PlayerBackpack(attrs); | ||
} | ||
|
||
@Test | ||
void putItem() { | ||
when(attrs.getAttack()).thenReturn(1); | ||
var weapon = | ||
new Item(1, "pach", "aaa", 1, new Attributes(1, 1, 1, 1, 1, 1), ItemType.WEAPON); | ||
var heavy = | ||
new Item(1, "pach", "aaa", 40, new Attributes(1, 1, 1, 1, 1, 1), ItemType.WEAPON); | ||
|
||
assertThat(bp.putItem(weapon)); | ||
assertThat(!bp.putItem(heavy)); | ||
assertThat(bp.getItems().size()).isEqualTo(1); | ||
assertThat(bp.getItems()).contains(weapon); | ||
} | ||
|
||
@Test | ||
void removeItem() { | ||
var weapon = | ||
new Item(1, "pach", "aaa", 1, new Attributes(1, 1, 1, 1, 1, 1), ItemType.WEAPON); | ||
|
||
assertThat(bp.putItem(weapon)); | ||
assertThat(bp.getItems()).contains(weapon); | ||
assertThat(bp.removeItem(weapon)); | ||
assertThat(bp.getItems()).isEmpty(); | ||
} | ||
|
||
@Test | ||
void getCapacity() { | ||
when(attrs.getAttack()).thenReturn(0); | ||
assertThat(bp.getCapacity()).isEqualTo(10); | ||
|
||
when(attrs.getAttack()).thenReturn(10); | ||
assertThat(bp.getCapacity()).isEqualTo(40); | ||
} | ||
} |
Oops, something went wrong.