Unit Test created and Classes created
This commit is contained in:
parent
891504ef09
commit
dcbb133489
124
.idea/uiDesigner.xml
generated
Normal file
124
.idea/uiDesigner.xml
generated
Normal file
@ -0,0 +1,124 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="Palette2">
|
||||
<group name="Swing">
|
||||
<item class="com.intellij.uiDesigner.HSpacer" tooltip-text="Horizontal Spacer" icon="/com/intellij/uiDesigner/icons/hspacer.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="1" hsize-policy="6" anchor="0" fill="1" />
|
||||
</item>
|
||||
<item class="com.intellij.uiDesigner.VSpacer" tooltip-text="Vertical Spacer" icon="/com/intellij/uiDesigner/icons/vspacer.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="1" anchor="0" fill="2" />
|
||||
</item>
|
||||
<item class="javax.swing.JPanel" icon="/com/intellij/uiDesigner/icons/panel.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3" />
|
||||
</item>
|
||||
<item class="javax.swing.JScrollPane" icon="/com/intellij/uiDesigner/icons/scrollPane.png" removable="false" auto-create-binding="false" can-attach-label="true">
|
||||
<default-constraints vsize-policy="7" hsize-policy="7" anchor="0" fill="3" />
|
||||
</item>
|
||||
<item class="javax.swing.JButton" icon="/com/intellij/uiDesigner/icons/button.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="3" anchor="0" fill="1" />
|
||||
<initial-values>
|
||||
<property name="text" value="Button" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JRadioButton" icon="/com/intellij/uiDesigner/icons/radioButton.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
|
||||
<initial-values>
|
||||
<property name="text" value="RadioButton" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JCheckBox" icon="/com/intellij/uiDesigner/icons/checkBox.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
|
||||
<initial-values>
|
||||
<property name="text" value="CheckBox" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JLabel" icon="/com/intellij/uiDesigner/icons/label.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="0" anchor="8" fill="0" />
|
||||
<initial-values>
|
||||
<property name="text" value="Label" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JTextField" icon="/com/intellij/uiDesigner/icons/textField.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||||
<preferred-size width="150" height="-1" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JPasswordField" icon="/com/intellij/uiDesigner/icons/passwordField.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||||
<preferred-size width="150" height="-1" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JFormattedTextField" icon="/com/intellij/uiDesigner/icons/formattedTextField.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||||
<preferred-size width="150" height="-1" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTextArea" icon="/com/intellij/uiDesigner/icons/textArea.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTextPane" icon="/com/intellij/uiDesigner/icons/textPane.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JEditorPane" icon="/com/intellij/uiDesigner/icons/editorPane.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JComboBox" icon="/com/intellij/uiDesigner/icons/comboBox.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="2" anchor="8" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JTable" icon="/com/intellij/uiDesigner/icons/table.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JList" icon="/com/intellij/uiDesigner/icons/list.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="2" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTree" icon="/com/intellij/uiDesigner/icons/tree.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTabbedPane" icon="/com/intellij/uiDesigner/icons/tabbedPane.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
|
||||
<preferred-size width="200" height="200" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JSplitPane" icon="/com/intellij/uiDesigner/icons/splitPane.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
|
||||
<preferred-size width="200" height="200" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JSpinner" icon="/com/intellij/uiDesigner/icons/spinner.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JSlider" icon="/com/intellij/uiDesigner/icons/slider.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JSeparator" icon="/com/intellij/uiDesigner/icons/separator.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3" />
|
||||
</item>
|
||||
<item class="javax.swing.JProgressBar" icon="/com/intellij/uiDesigner/icons/progressbar.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JToolBar" icon="/com/intellij/uiDesigner/icons/toolbar.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1">
|
||||
<preferred-size width="-1" height="20" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JToolBar$Separator" icon="/com/intellij/uiDesigner/icons/toolbarSeparator.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="0" anchor="0" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JScrollBar" icon="/com/intellij/uiDesigner/icons/scrollbar.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="0" anchor="0" fill="2" />
|
||||
</item>
|
||||
</group>
|
||||
</component>
|
||||
</project>
|
14
pom.xml
14
pom.xml
@ -7,6 +7,20 @@
|
||||
<groupId>at.reisinger.mtcg</groupId>
|
||||
<artifactId>MTCG</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>RELEASE</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter</artifactId>
|
||||
<version>RELEASE</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
||||
</project>
|
2
src/main/java/Battle.java
Normal file
2
src/main/java/Battle.java
Normal file
@ -0,0 +1,2 @@
|
||||
public class Battle {
|
||||
}
|
37
src/main/java/Card.java
Normal file
37
src/main/java/Card.java
Normal file
@ -0,0 +1,37 @@
|
||||
public class Card {
|
||||
public Card(String name, double damage, ElementTyp elementTyp, CardType cardType) {
|
||||
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return "";
|
||||
}
|
||||
|
||||
public int getDamage() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public ElementTyp getElementTyp() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public CardType getCardType() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public EffectivnessType getEffectivenessAgainst() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean setName(String neuerName) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean setDamage(int damage) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean setElementType(ElementTyp elementTyp) {
|
||||
return false;
|
||||
}
|
||||
}
|
3
src/main/java/CardType.java
Normal file
3
src/main/java/CardType.java
Normal file
@ -0,0 +1,3 @@
|
||||
public enum CardType {
|
||||
MONSTER, SPELL
|
||||
}
|
23
src/main/java/Cards.java
Normal file
23
src/main/java/Cards.java
Normal file
@ -0,0 +1,23 @@
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class Cards {
|
||||
public Cards(ArrayList<Card> cardsArrayList) {
|
||||
|
||||
}
|
||||
|
||||
public Cards() {
|
||||
|
||||
}
|
||||
|
||||
public void addCard(Card newCard) {
|
||||
|
||||
}
|
||||
|
||||
public ArrayList<Card> getCards() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean delCard(Card delCard) {
|
||||
return false;
|
||||
}
|
||||
}
|
21
src/main/java/Coins.java
Normal file
21
src/main/java/Coins.java
Normal file
@ -0,0 +1,21 @@
|
||||
public class Coins {
|
||||
public Coins(int coins) {
|
||||
|
||||
}
|
||||
|
||||
public int getCoinAmount() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public void addCoin(int coins) throws NegativAmountException{
|
||||
throw new NegativAmountException();
|
||||
}
|
||||
|
||||
public boolean removeCoin(int coins) throws NegativAmountException{
|
||||
throw new NegativAmountException();
|
||||
}
|
||||
|
||||
public boolean changeCoinAmmount(int coins) {
|
||||
return false;
|
||||
}
|
||||
}
|
2
src/main/java/Credentials.java
Normal file
2
src/main/java/Credentials.java
Normal file
@ -0,0 +1,2 @@
|
||||
public class Credentials {
|
||||
}
|
2
src/main/java/DBConnection.java
Normal file
2
src/main/java/DBConnection.java
Normal file
@ -0,0 +1,2 @@
|
||||
public class DBConnection {
|
||||
}
|
5
src/main/java/EffectivnessType.java
Normal file
5
src/main/java/EffectivnessType.java
Normal file
@ -0,0 +1,5 @@
|
||||
public enum EffectivnessType {
|
||||
EFFEKTIVE,
|
||||
NOTEFFEKTIVE,
|
||||
NOEFFEKT
|
||||
}
|
3
src/main/java/ElementTyp.java
Normal file
3
src/main/java/ElementTyp.java
Normal file
@ -0,0 +1,3 @@
|
||||
public enum ElementTyp {
|
||||
WATER, FIRE
|
||||
}
|
5
src/main/java/MonsterCard.java
Normal file
5
src/main/java/MonsterCard.java
Normal file
@ -0,0 +1,5 @@
|
||||
public class MonsterCard extends Card{
|
||||
public MonsterCard(String name, double damage, ElementTyp elementTyp, CardType cardType) {
|
||||
super(name, damage, elementTyp, cardType);
|
||||
}
|
||||
}
|
2
src/main/java/NegativAmountException.java
Normal file
2
src/main/java/NegativAmountException.java
Normal file
@ -0,0 +1,2 @@
|
||||
public class NegativAmountException extends Exception {
|
||||
}
|
17
src/main/java/Package.java
Normal file
17
src/main/java/Package.java
Normal file
@ -0,0 +1,17 @@
|
||||
public class Package extends Cards{
|
||||
public Package(Cards stack, Cards deck, String name, int price) {
|
||||
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public int getPrice() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public void setName(String neuName) {
|
||||
|
||||
}
|
||||
}
|
5
src/main/java/SpellCard.java
Normal file
5
src/main/java/SpellCard.java
Normal file
@ -0,0 +1,5 @@
|
||||
public class SpellCard extends Card{
|
||||
public SpellCard(String name, double damage, ElementTyp elementTyp, CardType cardType) {
|
||||
super(name, damage, elementTyp, cardType);
|
||||
}
|
||||
}
|
17
src/main/java/Stack.java
Normal file
17
src/main/java/Stack.java
Normal file
@ -0,0 +1,17 @@
|
||||
public class Stack extends Cards{
|
||||
public Stack(Cards cards, Cards nochNewCards) {
|
||||
|
||||
}
|
||||
|
||||
public void addDeck(Cards newCards) {
|
||||
|
||||
}
|
||||
|
||||
public Cards getDeck() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean delDeck(Cards delCards) {
|
||||
return false;
|
||||
}
|
||||
}
|
15
src/main/java/Store.java
Normal file
15
src/main/java/Store.java
Normal file
@ -0,0 +1,15 @@
|
||||
import java.util.ArrayList;
|
||||
|
||||
public interface Store {
|
||||
DBConnection db = new DBConnection();
|
||||
|
||||
void addTradingDeal(TradingDeal tradingDeal);
|
||||
|
||||
ArrayList<TradingDeal> getTradingDeals();
|
||||
|
||||
boolean doTrading(TradingDeal tradingDeal1, TradingDeal tradingDeal2);
|
||||
|
||||
ArrayList<TradingDeal> getPossibleTradingDeals();
|
||||
|
||||
ArrayList<TradingDeal> getPossibleAvailableTradingDeals();
|
||||
}
|
43
src/main/java/TradingDeal.java
Normal file
43
src/main/java/TradingDeal.java
Normal file
@ -0,0 +1,43 @@
|
||||
public class TradingDeal {
|
||||
public TradingDeal(User user, Card cardToTrade, ElementTyp requiredElementType, double requiredMinDamage, CardType requiredCardType) {
|
||||
}
|
||||
|
||||
public User getTradingUser() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public Card getCardToTrade() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public ElementTyp getRequiredElementType() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public int getRequiredMinDamage() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public CardType getRequiredCardType() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setTradingUser(User user) {
|
||||
|
||||
}
|
||||
|
||||
public void setCardToTrade(Card card) {
|
||||
|
||||
}
|
||||
|
||||
public void setRequiredElementType(ElementTyp elementTyp) {
|
||||
}
|
||||
|
||||
public void setRequiredMinDamage(int damage) {
|
||||
|
||||
}
|
||||
|
||||
public void setRequiredCardType(CardType cardType) {
|
||||
|
||||
}
|
||||
}
|
55
src/main/java/User.java
Normal file
55
src/main/java/User.java
Normal file
@ -0,0 +1,55 @@
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class User implements Store{
|
||||
public User(Credentials credentials, String name, String nachname, String email, Stack stack, Coins coins) {
|
||||
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public String getNachname() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public String getEmail() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public String setName(String name) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public String setNachname(String nachname) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public String setEmail(String email) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public Cards buyPackage(Package mypackage) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void addTradingDeal(TradingDeal tradingDeal) {
|
||||
|
||||
}
|
||||
|
||||
public ArrayList<TradingDeal> getTradingDeals() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean doTrading(TradingDeal tradingDeal1, TradingDeal tradingDeal2) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public ArrayList<TradingDeal> getPossibleTradingDeals() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public ArrayList<TradingDeal> getPossibleAvailableTradingDeals() {
|
||||
return null;
|
||||
}
|
||||
}
|
56
src/test/java/CardTest.java
Normal file
56
src/test/java/CardTest.java
Normal file
@ -0,0 +1,56 @@
|
||||
import org.junit.Test;
|
||||
|
||||
|
||||
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
public class CardTest {
|
||||
|
||||
@Test
|
||||
public void test_getName() {
|
||||
Card card = new Card("Name", 10, ElementTyp.WATER, CardType.SPELL);
|
||||
assertTrue(card.getName() != "");
|
||||
}
|
||||
@Test
|
||||
public void test_getDamage() {
|
||||
Card card = new Card("Name", 10, ElementTyp.WATER, CardType.SPELL);
|
||||
assertTrue(card.getDamage() >= 0);
|
||||
}
|
||||
@Test
|
||||
public void test_getElementType() {
|
||||
Card card = new Card("Name", 10, ElementTyp.WATER, CardType.SPELL);
|
||||
ElementTyp elementTyp = card.getElementTyp();
|
||||
assertTrue(elementTyp != null);
|
||||
}
|
||||
@Test
|
||||
public void test_getCardType() {
|
||||
Card card = new Card("Name", 10, ElementTyp.WATER, CardType.SPELL);
|
||||
CardType cardType = card.getCardType();
|
||||
assertTrue(cardType != null);
|
||||
}
|
||||
@Test
|
||||
public void test_getEffectivenessAgainst() {
|
||||
Card card = new Card("Name", 10, ElementTyp.WATER, CardType.SPELL);
|
||||
EffectivnessType effectivnessType = card.getEffectivenessAgainst();
|
||||
assertTrue(effectivnessType != null);
|
||||
}
|
||||
@Test
|
||||
public void test_setName() {
|
||||
Card card = new Card("Name", 10, ElementTyp.WATER, CardType.SPELL);
|
||||
boolean result = card.setName("NeuerName");
|
||||
assertTrue(result);
|
||||
}
|
||||
@Test
|
||||
public void test_setDamage() {
|
||||
Card card = new Card("Name", 10, ElementTyp.WATER, CardType.SPELL);
|
||||
boolean result = card.setDamage(100);
|
||||
assertTrue(result);
|
||||
}
|
||||
@Test
|
||||
public void test_setElementTyp() {
|
||||
Card card = new Card("Name", 10, ElementTyp.WATER, CardType.SPELL);
|
||||
boolean result = card.setElementType(ElementTyp.WATER);
|
||||
assertTrue(result);
|
||||
}
|
||||
}
|
37
src/test/java/CardsTest.java
Normal file
37
src/test/java/CardsTest.java
Normal file
@ -0,0 +1,37 @@
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class CardsTest {
|
||||
public Card newCard, card;
|
||||
public Cards cards;
|
||||
public ArrayList<Card> cardsArrayList;
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
card = new Card("Name", 10, ElementTyp.WATER, CardType.MONSTER);
|
||||
newCard = new Card("NameNew", 10, ElementTyp.WATER, CardType.SPELL);
|
||||
cardsArrayList = new ArrayList<Card>();
|
||||
cardsArrayList.add(card);
|
||||
cards = new Cards(cardsArrayList);
|
||||
}
|
||||
|
||||
@Test
|
||||
void test_addCard() {
|
||||
ArrayList<Card> result = cards.getCards();
|
||||
cards.addCard(newCard);
|
||||
cardsArrayList.add(newCard);
|
||||
assertTrue(result == cardsArrayList);
|
||||
}
|
||||
@Test
|
||||
void test_delCard() {
|
||||
boolean result = cards.delCard(newCard);
|
||||
assertTrue(result);
|
||||
}
|
||||
@Test
|
||||
void test_getCards() {
|
||||
ArrayList<Card> result = cards.getCards();
|
||||
assertTrue(result == cardsArrayList);
|
||||
}
|
||||
|
||||
}
|
62
src/test/java/CoinsTest.java
Normal file
62
src/test/java/CoinsTest.java
Normal file
@ -0,0 +1,62 @@
|
||||
import static org.hamcrest.CoreMatchers.allOf;
|
||||
import static org.hamcrest.CoreMatchers.anyOf;
|
||||
import static org.hamcrest.CoreMatchers.hasItems;
|
||||
import static org.hamcrest.CoreMatchers.not;
|
||||
import static org.hamcrest.core.Is.is;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
|
||||
public class CoinsTest {
|
||||
|
||||
@Test
|
||||
public void test_getCoinAmount(){
|
||||
Coins coin = new Coins(10);
|
||||
assertTrue("Fehler getCoinAmmount ist negativ",coin.getCoinAmount() >= 0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_addCoinException(){
|
||||
try {
|
||||
Coins coin = new Coins(10);
|
||||
coin.addCoin(-10);
|
||||
fail("Erwartet NegativAmountException - addCoin");
|
||||
}catch (NegativAmountException negativAmountException) {
|
||||
assertThat(negativAmountException.getMessage(), is("negativAmountException"));
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_removeCoinException(){
|
||||
try {
|
||||
Coins coin = new Coins(10);
|
||||
coin.removeCoin(-10);
|
||||
fail("Erwartet NegativAmountException - removeCoin");
|
||||
}catch (NegativAmountException negativAmountException) {
|
||||
assertThat(negativAmountException.getMessage(), is("negativAmountException"));
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_removeCoin(){
|
||||
Coins coin = new Coins(10);
|
||||
try {
|
||||
assertTrue(coin.removeCoin(10));
|
||||
} catch (NegativAmountException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_changeCoinAmount_true(){
|
||||
Coins coin = new Coins(10);
|
||||
assertTrue(coin.changeCoinAmmount(-10));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_changeCoinAmount_false(){
|
||||
Coins coin = new Coins(9);
|
||||
assertFalse(coin.changeCoinAmmount(-10));
|
||||
}
|
||||
}
|
46
src/test/java/PackageTest.java
Normal file
46
src/test/java/PackageTest.java
Normal file
@ -0,0 +1,46 @@
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
public class PackageTest {
|
||||
private Cards newCards, cards, nochNewCards;
|
||||
private Card newCard, card;
|
||||
private ArrayList<Card> cardsArrayList, cardsArrayList2, cardsArrayList3;
|
||||
private Package myPackage;
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
card = new Card("Name", 10, ElementTyp.WATER, CardType.MONSTER);
|
||||
newCard = new Card("NameNew", 10, ElementTyp.WATER, CardType.SPELL);
|
||||
cardsArrayList = new ArrayList<Card>();
|
||||
cardsArrayList2 = new ArrayList<Card>();
|
||||
cardsArrayList3 = new ArrayList<Card>();
|
||||
cardsArrayList.add(card);
|
||||
cardsArrayList2.add(newCard);
|
||||
cards = new Cards(cardsArrayList);
|
||||
newCards = new Cards(cardsArrayList2);
|
||||
nochNewCards = new Cards(cardsArrayList3);
|
||||
myPackage = new Package(cards, nochNewCards, "Name", 100);
|
||||
}
|
||||
|
||||
@Test
|
||||
void test_getName() {
|
||||
String result = myPackage.getName();
|
||||
assertTrue(result=="Name");
|
||||
}
|
||||
|
||||
@Test
|
||||
void test_getPrice() {
|
||||
int result = myPackage.getPrice();
|
||||
assertTrue(result==100);
|
||||
}
|
||||
|
||||
@Test
|
||||
void test_setName() {
|
||||
myPackage.setName("neuName");
|
||||
String result = myPackage.getName();
|
||||
assertTrue(result=="neuName");
|
||||
}
|
||||
}
|
43
src/test/java/StackTest.java
Normal file
43
src/test/java/StackTest.java
Normal file
@ -0,0 +1,43 @@
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
public class StackTest {
|
||||
private Cards newCards, cards, nochNewCards;
|
||||
private Card newCard, card;
|
||||
private ArrayList<Card> cardsArrayList, cardsArrayList2, cardsArrayList3;
|
||||
private Stack stack;
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
card = new Card("Name", 10, ElementTyp.WATER, CardType.MONSTER);
|
||||
newCard = new Card("NameNew", 10, ElementTyp.WATER, CardType.SPELL);
|
||||
cardsArrayList = new ArrayList<Card>();
|
||||
cardsArrayList2 = new ArrayList<Card>();
|
||||
cardsArrayList3 = new ArrayList<Card>();
|
||||
cardsArrayList.add(card);
|
||||
cardsArrayList2.add(newCard);
|
||||
cards = new Cards(cardsArrayList);
|
||||
newCards = new Cards(cardsArrayList2);
|
||||
nochNewCards = new Cards(cardsArrayList3);
|
||||
stack = new Stack(cards, nochNewCards);
|
||||
}
|
||||
@Test
|
||||
void test_addDeck() {
|
||||
stack.addDeck(newCards);
|
||||
Cards result = stack.getDeck();
|
||||
assertTrue(result == newCards);
|
||||
}
|
||||
@Test
|
||||
void test_delDeck() {
|
||||
boolean result = stack.delDeck(cards);
|
||||
assertTrue(result);
|
||||
}
|
||||
@Test
|
||||
void test_getDeck() {
|
||||
Cards result = stack.getDeck();
|
||||
assertTrue(result == cards);
|
||||
}
|
||||
}
|
82
src/test/java/StoreTest.java
Normal file
82
src/test/java/StoreTest.java
Normal file
@ -0,0 +1,82 @@
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
public class StoreTest {
|
||||
|
||||
private TradingDeal tradingDeal;
|
||||
private Cards newCards, cards, nochNewCards;
|
||||
private Card newCard, card;
|
||||
private ArrayList<Card> cardsArrayList, cardsArrayList2, cardsArrayList3;
|
||||
private Stack stack;
|
||||
private User user, userNew;
|
||||
private Store store;
|
||||
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
//Stack
|
||||
card = new Card("Name", 10, ElementTyp.WATER, CardType.MONSTER);
|
||||
newCard = new Card("NameNew", 10, ElementTyp.WATER, CardType.SPELL);
|
||||
cardsArrayList = new ArrayList<Card>();
|
||||
cardsArrayList2 = new ArrayList<Card>();
|
||||
cardsArrayList3 = new ArrayList<Card>();
|
||||
cardsArrayList.add(card);
|
||||
cardsArrayList2.add(newCard);
|
||||
cards = new Cards(cardsArrayList);
|
||||
newCards = new Cards(cardsArrayList2);
|
||||
nochNewCards = new Cards(cardsArrayList3);
|
||||
stack = new Stack(cards, nochNewCards);
|
||||
|
||||
//Coins
|
||||
Coins coins = new Coins(10);
|
||||
//User
|
||||
Credentials credentials = new Credentials();
|
||||
user = new User(credentials, "name", "nachname", "email", stack, coins);
|
||||
userNew = new User(credentials, "nameNew", "nachnameNew", "emailNew", stack, coins);
|
||||
|
||||
//Trading Deal
|
||||
Card cardToTrade = card;
|
||||
ElementTyp requiredElementType = ElementTyp.FIRE;
|
||||
double requiredMinDamage = 100;
|
||||
CardType requiredCardType = CardType.MONSTER;
|
||||
tradingDeal = new TradingDeal(user, cardToTrade, requiredElementType, requiredMinDamage, requiredCardType);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
void test_addTradingDeal() {
|
||||
user.addTradingDeal(tradingDeal);
|
||||
ArrayList<TradingDeal> expected = new ArrayList<TradingDeal>();
|
||||
expected.add(tradingDeal);
|
||||
assertTrue(user.getTradingDeals() == expected);
|
||||
}
|
||||
@Test
|
||||
void test_doTrade() {
|
||||
boolean result = user.doTrading(tradingDeal, tradingDeal);
|
||||
assertTrue(result);
|
||||
}
|
||||
@Test
|
||||
void test_getTradingDeals() {
|
||||
ArrayList<TradingDeal> result = user.getTradingDeals();
|
||||
ArrayList<TradingDeal> expected = new ArrayList<TradingDeal>();
|
||||
expected.add(tradingDeal);
|
||||
assertTrue(result == expected);
|
||||
}
|
||||
@Test
|
||||
void test_getPossibleTradingDeals() {
|
||||
ArrayList<TradingDeal> result = user.getPossibleTradingDeals();
|
||||
ArrayList<TradingDeal> expected = new ArrayList<TradingDeal>();
|
||||
expected.add(tradingDeal);
|
||||
assertTrue(result == expected);
|
||||
}
|
||||
@Test
|
||||
void test_getAvailableTradingDeals() {
|
||||
ArrayList<TradingDeal> result = user.getPossibleAvailableTradingDeals();
|
||||
ArrayList<TradingDeal> expected = new ArrayList<TradingDeal>();
|
||||
expected.add(tradingDeal);
|
||||
assertTrue(result == expected);
|
||||
}
|
||||
}
|
103
src/test/java/TradingDealTest.java
Normal file
103
src/test/java/TradingDealTest.java
Normal file
@ -0,0 +1,103 @@
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
public class TradingDealTest {
|
||||
|
||||
private TradingDeal tradingDeal;
|
||||
private Cards newCards, cards, nochNewCards;
|
||||
private Card newCard, card;
|
||||
private ArrayList<Card> cardsArrayList, cardsArrayList2, cardsArrayList3;
|
||||
private Stack stack;
|
||||
private User user, userNew;
|
||||
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
//Stack
|
||||
card = new Card("Name", 10, ElementTyp.WATER, CardType.MONSTER);
|
||||
newCard = new Card("NameNew", 10, ElementTyp.WATER, CardType.SPELL);
|
||||
cardsArrayList = new ArrayList<Card>();
|
||||
cardsArrayList2 = new ArrayList<Card>();
|
||||
cardsArrayList3 = new ArrayList<Card>();
|
||||
cardsArrayList.add(card);
|
||||
cardsArrayList2.add(newCard);
|
||||
cards = new Cards(cardsArrayList);
|
||||
newCards = new Cards(cardsArrayList2);
|
||||
nochNewCards = new Cards(cardsArrayList3);
|
||||
stack = new Stack(cards, nochNewCards);
|
||||
|
||||
//Coins
|
||||
Coins coins = new Coins(10);
|
||||
//User
|
||||
Credentials credentials = new Credentials();
|
||||
user = new User(credentials, "name", "nachname", "email", stack, coins);
|
||||
userNew = new User(credentials, "nameNew", "nachnameNew", "emailNew", stack, coins);
|
||||
|
||||
//Trading Deal
|
||||
Card cardToTrade = card;
|
||||
ElementTyp requiredElementType = ElementTyp.FIRE;
|
||||
double requiredMinDamage = 100;
|
||||
CardType requiredCardType = CardType.MONSTER;
|
||||
tradingDeal = new TradingDeal(user, cardToTrade, requiredElementType, requiredMinDamage, requiredCardType);
|
||||
}
|
||||
|
||||
@Test
|
||||
void test_getTradingUser() {
|
||||
User result = tradingDeal.getTradingUser();
|
||||
assertTrue(result==user);
|
||||
}
|
||||
@Test
|
||||
void test_getCardToTrade() {
|
||||
Card result = tradingDeal.getCardToTrade();
|
||||
assertTrue(result==card);
|
||||
}
|
||||
@Test
|
||||
void test_getRequiredElementType() {
|
||||
ElementTyp result = tradingDeal.getRequiredElementType();
|
||||
assertTrue(result==ElementTyp.FIRE);
|
||||
}
|
||||
@Test
|
||||
void test_getRequiredMinDamage() {
|
||||
int result = tradingDeal.getRequiredMinDamage();
|
||||
assertTrue(result==100);
|
||||
}
|
||||
@Test
|
||||
void test_getRequiredCardType() {
|
||||
CardType result = tradingDeal.getRequiredCardType();
|
||||
assertTrue(result==CardType.MONSTER);
|
||||
}
|
||||
|
||||
@Test
|
||||
void test_setTradingUser() {
|
||||
tradingDeal.setTradingUser(userNew);
|
||||
User result = tradingDeal.getTradingUser();
|
||||
assertTrue(result==userNew);
|
||||
}
|
||||
@Test
|
||||
void test_setCardToTrade() {
|
||||
tradingDeal.setCardToTrade(newCard);
|
||||
Card result = tradingDeal.getCardToTrade();
|
||||
assertTrue(result==newCard);
|
||||
}
|
||||
@Test
|
||||
void test_setRequiredElementType() {
|
||||
tradingDeal.setRequiredElementType(ElementTyp.WATER);
|
||||
ElementTyp result = tradingDeal.getRequiredElementType();
|
||||
assertTrue(result==ElementTyp.WATER);
|
||||
}
|
||||
@Test
|
||||
void test_setRequiredMinDamage() {
|
||||
tradingDeal.setRequiredMinDamage(10);
|
||||
int result = tradingDeal.getRequiredMinDamage();
|
||||
assertTrue(result==10);
|
||||
}
|
||||
@Test
|
||||
void test_setRequiredCardType() {
|
||||
tradingDeal.setRequiredCardType(CardType.SPELL);
|
||||
CardType result = tradingDeal.getRequiredCardType();
|
||||
assertTrue(result==CardType.SPELL);
|
||||
}
|
||||
}
|
79
src/test/java/UserTest.java
Normal file
79
src/test/java/UserTest.java
Normal file
@ -0,0 +1,79 @@
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
public class UserTest {
|
||||
private TradingDeal tradingDeal;
|
||||
private Cards newCards, cards, nochNewCards;
|
||||
private Card newCard, card;
|
||||
private ArrayList<Card> cardsArrayList, cardsArrayList2, cardsArrayList3;
|
||||
private Stack stack;
|
||||
private User user;
|
||||
private Package myPackage;
|
||||
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
//Stack
|
||||
card = new Card("Name", 10, ElementTyp.WATER, CardType.MONSTER);
|
||||
newCard = new Card("NameNew", 10, ElementTyp.WATER, CardType.SPELL);
|
||||
cardsArrayList = new ArrayList<Card>();
|
||||
cardsArrayList2 = new ArrayList<Card>();
|
||||
cardsArrayList3 = new ArrayList<Card>();
|
||||
cardsArrayList.add(card);
|
||||
cardsArrayList2.add(newCard);
|
||||
cards = new Cards(cardsArrayList);
|
||||
newCards = new Cards(cardsArrayList2);
|
||||
nochNewCards = new Cards(cardsArrayList3);
|
||||
stack = new Stack(cards, nochNewCards);
|
||||
//Package
|
||||
myPackage = new Package(cards, nochNewCards, "Name", 100);
|
||||
|
||||
//Coins
|
||||
Coins coins = new Coins(10);
|
||||
//User
|
||||
Credentials credentials = new Credentials();
|
||||
user = new User(credentials, "name", "nachname", "email", stack, coins);
|
||||
}
|
||||
@Test
|
||||
public void test_getName() {
|
||||
String result = user.getName();
|
||||
assertTrue(result != "");
|
||||
}
|
||||
@Test
|
||||
public void test_getNachname() {
|
||||
String result = user.getNachname();
|
||||
assertTrue(result != "");
|
||||
}
|
||||
@Test
|
||||
public void test_getEmail() {
|
||||
String result = user.getEmail();
|
||||
assertTrue(result != "");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_setName() {
|
||||
String newstring = "new";
|
||||
String result = user.setName(newstring);
|
||||
assertTrue(result != newstring);
|
||||
}
|
||||
@Test
|
||||
public void test_setNachname() {
|
||||
String newstring = "new";
|
||||
String result = user.setNachname(newstring);
|
||||
assertTrue(result != newstring);
|
||||
}
|
||||
@Test
|
||||
public void test_setEmail() {
|
||||
String newstring = "new";
|
||||
String result = user.setEmail(newstring);
|
||||
assertTrue(result != newstring);
|
||||
}
|
||||
@Test
|
||||
public void test_buyPackage(){
|
||||
Cards cards = user.buyPackage(myPackage);
|
||||
assertTrue(cards != null);
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user