JUnit verbessert
This commit is contained in:
parent
95873d7e6d
commit
e86ce341de
@ -83,7 +83,7 @@ public class Card {
|
|||||||
* @param neuerName Name der Card
|
* @param neuerName Name der Card
|
||||||
*/
|
*/
|
||||||
public void setName(String neuerName) {
|
public void setName(String neuerName) {
|
||||||
this.name = name;
|
this.name = neuerName;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -15,12 +16,7 @@ public class Cards {
|
|||||||
this.cards = cardsArrayList;
|
this.cards = cardsArrayList;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Erstellt ein neues Obj ohne Cards
|
|
||||||
*/
|
|
||||||
public Cards() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fügt eine neue Card hinzu
|
* Fügt eine neue Card hinzu
|
||||||
@ -56,6 +52,8 @@ public class Cards {
|
|||||||
this.cards.forEach(item -> {
|
this.cards.forEach(item -> {
|
||||||
if(item.getElementTyp().equals(toCeck.getElementTyp()) && item.getCardType().equals(toCeck.getCardType()) && item.getName().equals(toCeck.getName()) && item.getDamage() == toCeck.getDamage()){
|
if(item.getElementTyp().equals(toCeck.getElementTyp()) && item.getCardType().equals(toCeck.getCardType()) && item.getName().equals(toCeck.getName()) && item.getDamage() == toCeck.getDamage()){
|
||||||
returnval.set(true);
|
returnval.set(true);
|
||||||
|
}else{
|
||||||
|
returnval.set(false);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return returnval.get();
|
return returnval.get();
|
||||||
@ -67,12 +65,14 @@ public class Cards {
|
|||||||
* @return True wenn es aus den selben Cards besteht
|
* @return True wenn es aus den selben Cards besteht
|
||||||
*/
|
*/
|
||||||
public boolean equals(Cards toCompare){
|
public boolean equals(Cards toCompare){
|
||||||
AtomicBoolean returnval = new AtomicBoolean(false);
|
if (this.cards == null && toCompare.getCards() == null){
|
||||||
this.cards.forEach(item -> {
|
return true;
|
||||||
if(toCompare.containsCard(item)){
|
}else if ((this.cards == null && toCompare.getCards() != null) || (this.cards != null && toCompare.getCards() == null)){
|
||||||
returnval.set(true);
|
return false;
|
||||||
}
|
}else if(this.cards.containsAll(toCompare.getCards()) && toCompare.getCards().containsAll(this.cards)){
|
||||||
});
|
return true;
|
||||||
return returnval.get();
|
}else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,13 +22,13 @@ public class Credentials {
|
|||||||
return passwort;
|
return passwort;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
// /**
|
||||||
* Setzt das User Passwort
|
// * Setzt das User Passwort
|
||||||
* @param passwort Neues Passwort
|
// * @param passwort Neues Passwort
|
||||||
*/
|
// */
|
||||||
public void setPasswort(String passwort) {
|
// public void setPasswort(String passwort) {
|
||||||
this.passwort = passwort;
|
// this.passwort = passwort;
|
||||||
}
|
// }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holt den Usernamen des Users
|
* Holt den Usernamen des Users
|
||||||
@ -38,11 +38,11 @@ public class Credentials {
|
|||||||
return username;
|
return username;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
// /**
|
||||||
* Setzt einen neuen Usernamen
|
// * Setzt einen neuen Usernamen
|
||||||
* @param username Neuer Username
|
// * @param username Neuer Username
|
||||||
*/
|
// */
|
||||||
public void setUsername(String username) {
|
// public void setUsername(String username) {
|
||||||
this.username = username;
|
// this.username = username;
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
@ -18,15 +18,19 @@ public class DBConnection {
|
|||||||
Card c3 = new Card("Name2", 13, ElementTyp.WATER, CardType.MONSTER);
|
Card c3 = new Card("Name2", 13, ElementTyp.WATER, CardType.MONSTER);
|
||||||
Card c4 = new Card("Name3", 14, ElementTyp.WATER, CardType.SPELL);
|
Card c4 = new Card("Name3", 14, ElementTyp.WATER, CardType.SPELL);
|
||||||
Card c5 = new Card("Name4", 15, ElementTyp.FIRE, CardType.MONSTER);
|
Card c5 = new Card("Name4", 15, ElementTyp.FIRE, CardType.MONSTER);
|
||||||
Cards deck = new Cards();
|
ArrayList<Card> deckArrList = new ArrayList<Card>();
|
||||||
Cards stack = new Cards();
|
ArrayList<Card> stackArrList = new ArrayList<Card>();
|
||||||
deck.addCard(c1);
|
deckArrList.add(c1);
|
||||||
deck.addCard(c2);
|
deckArrList.add(c2);
|
||||||
stack.addCard(c3);
|
stackArrList.add(c3);
|
||||||
stack.addCard(c4);
|
stackArrList.add(c4);
|
||||||
stack.addCard(c5);
|
stackArrList.add(c5);
|
||||||
|
Cards deck = new Cards(deckArrList);
|
||||||
|
Cards stack = new Cards(stackArrList);
|
||||||
User user = new User(new Credentials("username", "passwort"), "Name", "Nachname", "Email", new Stack(stack, deck), new Coins(1000));
|
User user = new User(new Credentials("username", "passwort"), "Name", "Nachname", "Email", new Stack(stack, deck), new Coins(1000));
|
||||||
this.tradingDeals.add(new TradingDeal(user, c1, ElementTyp.FIRE, 10, CardType.SPELL));
|
this.tradingDeals = new ArrayList<TradingDeal>();
|
||||||
|
this.packages = new ArrayList<Package>();
|
||||||
|
this.tradingDeals.add(new TradingDeal(user, c1, ElementTyp.FIRE, 10, CardType.MONSTER));
|
||||||
this.packages.add(new Package(stack, "Test Package", 100));
|
this.packages.add(new Package(stack, "Test Package", 100));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -54,11 +58,11 @@ public class DBConnection {
|
|||||||
this.tradingDeals.add(tradingDeal);
|
this.tradingDeals.add(tradingDeal);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
// /**
|
||||||
* Fügt ein neues Package zu dem Store hinzu
|
// * Fügt ein neues Package zu dem Store hinzu
|
||||||
* @param packageDeal Das neue Package
|
// * @param packageDeal Das neue Package
|
||||||
*/
|
// */
|
||||||
public void addPackage(Package packageDeal){
|
// public void addPackage(Package packageDeal){
|
||||||
this.packages.add(packageDeal);
|
// this.packages.add(packageDeal);
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
@ -38,11 +38,11 @@ public class Stack extends Cards{
|
|||||||
this.deck.delCard(toDel);
|
this.deck.delCard(toDel);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
// /**
|
||||||
* Fügt dem deck eine neue Card ein
|
// * Fügt dem deck eine neue Card ein
|
||||||
* @param toAdd Neue Card
|
// * @param toAdd Neue Card
|
||||||
*/
|
// */
|
||||||
public void addDeckCard(Card toAdd){
|
// public void addDeckCard(Card toAdd){
|
||||||
this.deck.addCard(toAdd);
|
// this.deck.addCard(toAdd);
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
@ -119,9 +119,22 @@ public class TradingDeal {
|
|||||||
* @return True wenn der Deal passt
|
* @return True wenn der Deal passt
|
||||||
*/
|
*/
|
||||||
public boolean cardOk(Card checkCard){
|
public boolean cardOk(Card checkCard){
|
||||||
|
System.out.println(checkCard.getCardType().equals(this.requiredCardType));
|
||||||
|
System.out.println(checkCard.getCardType().toString());
|
||||||
|
System.out.println(this.requiredCardType.toString());
|
||||||
|
System.out.println(" ");
|
||||||
|
System.out.println(checkCard.getElementTyp().equals(this.requiredElementType));
|
||||||
|
System.out.println(checkCard.getElementTyp().toString());
|
||||||
|
System.out.println(this.requiredElementType);
|
||||||
|
System.out.println(" ");
|
||||||
|
System.out.println(checkCard.getDamage() >= this.requiredMinDamage);
|
||||||
|
System.out.println(checkCard.getDamage());
|
||||||
|
System.out.println(this.requiredMinDamage);
|
||||||
if(checkCard.getCardType().equals(this.requiredCardType) && checkCard.getElementTyp().equals(this.requiredElementType) && checkCard.getDamage() >= this.requiredMinDamage){
|
if(checkCard.getCardType().equals(this.requiredCardType) && checkCard.getElementTyp().equals(this.requiredElementType) && checkCard.getDamage() >= this.requiredMinDamage){
|
||||||
|
System.out.println("Da simma true");
|
||||||
return true;
|
return true;
|
||||||
}else {
|
}else {
|
||||||
|
System.out.println("da simma false");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,7 @@ public class User implements Store{
|
|||||||
this.email = email;
|
this.email = email;
|
||||||
this.stack = stack;
|
this.stack = stack;
|
||||||
this.coins = coins;
|
this.coins = coins;
|
||||||
this.db = new DBConnection();
|
//this.db = new DBConnection();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -50,7 +50,7 @@ public class User implements Store{
|
|||||||
* @return Das DB Obj
|
* @return Das DB Obj
|
||||||
*/
|
*/
|
||||||
public DBConnection getDb() {
|
public DBConnection getDb() {
|
||||||
return db;
|
return new DBConnection();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -150,7 +150,7 @@ public class User implements Store{
|
|||||||
* @throws NegativAmountException Wenn ein negativer Preis im Package gesetzt wird.
|
* @throws NegativAmountException Wenn ein negativer Preis im Package gesetzt wird.
|
||||||
*/
|
*/
|
||||||
public ArrayList<Card> buyPackage(Package mypackage) throws NegativAmountException {
|
public ArrayList<Card> buyPackage(Package mypackage) throws NegativAmountException {
|
||||||
ArrayList<Package> availablePackages = db.getAllPackages();
|
ArrayList<Package> availablePackages = new DBConnection().getAllPackages();
|
||||||
availablePackages.removeIf(obj -> obj.equals(mypackage));
|
availablePackages.removeIf(obj -> obj.equals(mypackage));
|
||||||
this.coins.removeCoin(mypackage.getPrice());
|
this.coins.removeCoin(mypackage.getPrice());
|
||||||
return mypackage.getCards();
|
return mypackage.getCards();
|
||||||
@ -161,7 +161,7 @@ public class User implements Store{
|
|||||||
* @param tradingDeal Der neue Tradingdeal
|
* @param tradingDeal Der neue Tradingdeal
|
||||||
*/
|
*/
|
||||||
public void addTradingDeal(TradingDeal tradingDeal) {
|
public void addTradingDeal(TradingDeal tradingDeal) {
|
||||||
db.addTradingDeal(tradingDeal);
|
new DBConnection().addTradingDeal(tradingDeal);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -169,7 +169,7 @@ public class User implements Store{
|
|||||||
* @return Alle verfügbaren Deals
|
* @return Alle verfügbaren Deals
|
||||||
*/
|
*/
|
||||||
public ArrayList<TradingDeal> getTradingDeals() {
|
public ArrayList<TradingDeal> getTradingDeals() {
|
||||||
return db.getAllTradingDeals();
|
return new DBConnection().getAllTradingDeals();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -182,6 +182,7 @@ public class User implements Store{
|
|||||||
if (storeTradingDeal.dealOk(myTradingDeal)){
|
if (storeTradingDeal.dealOk(myTradingDeal)){
|
||||||
stack.delCard(myTradingDeal.getCardToTrade());
|
stack.delCard(myTradingDeal.getCardToTrade());
|
||||||
stack.addCard(storeTradingDeal.getCardToTrade());
|
stack.addCard(storeTradingDeal.getCardToTrade());
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -193,10 +194,11 @@ public class User implements Store{
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public ArrayList<TradingDeal> getPossibleTradingDeals(Card toTrade) {
|
public ArrayList<TradingDeal> getPossibleTradingDeals(Card toTrade) {
|
||||||
ArrayList<TradingDeal> storeList = db.getAllTradingDeals();
|
ArrayList<TradingDeal> storeList = new DBConnection().getAllTradingDeals();
|
||||||
ArrayList<TradingDeal> possible = new ArrayList<TradingDeal>();
|
ArrayList<TradingDeal> possible = new ArrayList<TradingDeal>();
|
||||||
storeList.forEach(item -> {
|
storeList.forEach(item -> {
|
||||||
if(item.cardOk(toTrade)){
|
if(item.cardOk(toTrade)){
|
||||||
|
System.out.println("ADDED ein item");
|
||||||
possible.add(item);
|
possible.add(item);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -18,20 +18,20 @@ public class CardTest {
|
|||||||
public void test_getElementType() {
|
public void test_getElementType() {
|
||||||
Card card = new Card("Name", 10, ElementTyp.WATER, CardType.SPELL);
|
Card card = new Card("Name", 10, ElementTyp.WATER, CardType.SPELL);
|
||||||
ElementTyp elementTyp = card.getElementTyp();
|
ElementTyp elementTyp = card.getElementTyp();
|
||||||
assertTrue(elementTyp != ElementTyp.WATER);
|
assertTrue(elementTyp == ElementTyp.WATER);
|
||||||
}
|
}
|
||||||
@Test
|
@Test
|
||||||
public void test_getCardType() {
|
public void test_getCardType() {
|
||||||
Card card = new Card("Name", 10, ElementTyp.WATER, CardType.SPELL);
|
Card card = new Card("Name", 10, ElementTyp.WATER, CardType.SPELL);
|
||||||
CardType cardType = card.getCardType();
|
CardType cardType = card.getCardType();
|
||||||
assertTrue(cardType != CardType.SPELL);
|
assertTrue(cardType == CardType.SPELL);
|
||||||
}
|
}
|
||||||
@Test
|
@Test
|
||||||
public void test_getEffectivenessAgainst() {
|
public void test_getEffectivenessAgainst() {
|
||||||
Card card = new Card("Name", 10, ElementTyp.WATER, CardType.MONSTER);
|
Card card = new Card("Name", 10, ElementTyp.WATER, CardType.MONSTER);
|
||||||
Card card2 = new Card("Name", 10, ElementTyp.WATER, CardType.MONSTER);
|
Card card2 = new Card("Name", 10, ElementTyp.WATER, CardType.MONSTER);
|
||||||
EffectivnessType effectivnessType = card.getEffectivenessAgainst(card2);
|
EffectivnessType effectivnessType = card.getEffectivenessAgainst(card2);
|
||||||
assertTrue(effectivnessType != EffectivnessType.NOEFFECT);
|
assertTrue(effectivnessType == EffectivnessType.NOEFFECT);
|
||||||
}
|
}
|
||||||
@Test
|
@Test
|
||||||
public void test_setName() {
|
public void test_setName() {
|
||||||
|
@ -2,38 +2,66 @@ import org.junit.jupiter.api.BeforeEach;
|
|||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
public class CardsTest {
|
public class CardsTest {
|
||||||
private Cards newCards, cards, nochNewCards;
|
private Cards cards, cards2, cards3;
|
||||||
private Card newCard, card;
|
private Card newCard, card, newerCard;
|
||||||
private ArrayList<Card> cardsArrayList, cardsArrayList2, cardsArrayList3;
|
private ArrayList<Card> cardsArrayList, cardsArrayList2, cardsArrayList3;
|
||||||
private Stack stack;
|
|
||||||
|
|
||||||
@BeforeEach
|
@BeforeEach
|
||||||
void setUp() {
|
void setUp() {
|
||||||
card = new Card("Name", 10, ElementTyp.WATER, CardType.MONSTER);
|
card = new Card("Name", 10, ElementTyp.WATER, CardType.MONSTER);
|
||||||
newCard = new Card("NameNew", 10, ElementTyp.WATER, CardType.SPELL);
|
newCard = new Card("NameNew", 10, ElementTyp.WATER, CardType.SPELL);
|
||||||
|
newerCard = new Card("NameNewerer", 100, ElementTyp.FIRE, CardType.MONSTER);
|
||||||
cardsArrayList = new ArrayList<Card>();
|
cardsArrayList = new ArrayList<Card>();
|
||||||
cardsArrayList2 = new ArrayList<Card>();
|
cardsArrayList2 = new ArrayList<Card>();
|
||||||
cardsArrayList3 = new ArrayList<Card>();
|
cardsArrayList3 = new ArrayList<Card>();
|
||||||
cardsArrayList.add(card);
|
cardsArrayList.add(card);
|
||||||
cardsArrayList2.add(newCard);
|
cardsArrayList2.add(newCard);
|
||||||
cardsArrayList2.add(card);
|
cardsArrayList2.add(card);
|
||||||
|
cardsArrayList3.add(newerCard);
|
||||||
cards = new Cards(cardsArrayList);
|
cards = new Cards(cardsArrayList);
|
||||||
newCards = new Cards(cardsArrayList2);
|
cards2 = new Cards(cardsArrayList2);
|
||||||
nochNewCards = new Cards(cardsArrayList3);
|
cards3 = new Cards(cardsArrayList3);
|
||||||
stack = new Stack(cards, nochNewCards);
|
|
||||||
}
|
}
|
||||||
@Test
|
@Test
|
||||||
void test_addCard() {
|
void test_addCard() {
|
||||||
|
System.out.println(cards.getCards().toString());
|
||||||
cards.addCard(newCard);
|
cards.addCard(newCard);
|
||||||
assertTrue(cards.getCards().equals(cardsArrayList2));
|
System.out.println(cards.getCards().toString());
|
||||||
|
System.out.println(cards2.getCards().toString());
|
||||||
|
assertTrue(cards.equals(cards2));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void test_addCard2() {
|
||||||
|
cards.addCard(newCard);
|
||||||
|
assertFalse(cards.equals(cards3));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void test_equals() {
|
||||||
|
assertFalse(cards.equals(cards2));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void test_contains() {
|
||||||
|
assertTrue(cards2.containsCard(card));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void test_contains2() {
|
||||||
|
assertFalse(cards.containsCard(newCard));
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void test_delCard() {
|
void test_delCard() {
|
||||||
cards.addCard(newCard);
|
cards.addCard(newCard);
|
||||||
|
|
||||||
cards.delCard(newCard);
|
cards.delCard(newCard);
|
||||||
|
|
||||||
assertTrue(cards.getCards().equals(cardsArrayList));
|
assertTrue(cards.getCards().equals(cardsArrayList));
|
||||||
}
|
}
|
||||||
@Test
|
@Test
|
||||||
|
@ -42,6 +42,6 @@ public class StackTest {
|
|||||||
@Test
|
@Test
|
||||||
void test_getDeck() {
|
void test_getDeck() {
|
||||||
Cards result = stack.getDeck();
|
Cards result = stack.getDeck();
|
||||||
assertTrue(result.equals(cards));
|
assertTrue(result.equals(nochNewCards));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,7 @@ public class StoreTest {
|
|||||||
@BeforeEach
|
@BeforeEach
|
||||||
void setUp() {
|
void setUp() {
|
||||||
//Stack
|
//Stack
|
||||||
card = new Card("Name", 10, ElementTyp.WATER, CardType.MONSTER);
|
card = new Card("Name", 100, ElementTyp.WATER, CardType.MONSTER);
|
||||||
newCard = new Card("NameNew", 10, ElementTyp.WATER, CardType.SPELL);
|
newCard = new Card("NameNew", 10, ElementTyp.WATER, CardType.SPELL);
|
||||||
cardsArrayList = new ArrayList<Card>();
|
cardsArrayList = new ArrayList<Card>();
|
||||||
cardsArrayList2 = new ArrayList<Card>();
|
cardsArrayList2 = new ArrayList<Card>();
|
||||||
@ -48,28 +48,41 @@ public class StoreTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void test_addTradingDeal() {
|
void test_addTradingDeal() {
|
||||||
user.addTradingDeal(tradingDeal);
|
|
||||||
ArrayList<TradingDeal> expected = new ArrayList<TradingDeal>();
|
|
||||||
expected.add(tradingDeal);
|
|
||||||
Card c1 = new Card("Name", 10, ElementTyp.FIRE, CardType.MONSTER);
|
Card c1 = new Card("Name", 10, ElementTyp.FIRE, CardType.MONSTER);
|
||||||
Card c2 = new Card("Name1", 12, ElementTyp.FIRE, CardType.SPELL);
|
Card c2 = new Card("Name1", 12, ElementTyp.FIRE, CardType.SPELL);
|
||||||
Card c3 = new Card("Name2", 13, ElementTyp.WATER, CardType.MONSTER);
|
Card c3 = new Card("Name2", 13, ElementTyp.WATER, CardType.MONSTER);
|
||||||
Card c4 = new Card("Name3", 14, ElementTyp.WATER, CardType.SPELL);
|
Card c4 = new Card("Name3", 14, ElementTyp.WATER, CardType.SPELL);
|
||||||
Card c5 = new Card("Name4", 15, ElementTyp.FIRE, CardType.MONSTER);
|
Card c5 = new Card("Name4", 15, ElementTyp.FIRE, CardType.MONSTER);
|
||||||
Cards deck = new Cards();
|
ArrayList<Card> deckArrList = new ArrayList<Card>();
|
||||||
Cards stack = new Cards();
|
ArrayList<Card> stackArrList = new ArrayList<Card>();
|
||||||
deck.addCard(c1);
|
deckArrList.add(c1);
|
||||||
deck.addCard(c2);
|
deckArrList.add(c2);
|
||||||
stack.addCard(c3);
|
stackArrList.add(c3);
|
||||||
stack.addCard(c4);
|
stackArrList.add(c4);
|
||||||
stack.addCard(c5);
|
stackArrList.add(c5);
|
||||||
TradingDeal vonDB = new TradingDeal(new User(new Credentials("username", "passwort"), "Name", "Nachname", "Email", new Stack(stack, deck), new Coins(1000)), c1, ElementTyp.FIRE, 10, CardType.SPELL);
|
Cards deck = new Cards(deckArrList);
|
||||||
expected.add(vonDB);
|
Cards stack = new Cards(stackArrList);
|
||||||
assertTrue(user.getTradingDeals().equals(expected));
|
User user = new User(new Credentials("username", "passwort"), "Name", "Nachname", "Email", new Stack(stack, deck), new Coins(1000));
|
||||||
|
ArrayList<TradingDeal> tradingDeals = new ArrayList<TradingDeal>();
|
||||||
|
ArrayList<Package> packages = new ArrayList<Package>();
|
||||||
|
tradingDeals.add(new TradingDeal(user, c1, ElementTyp.FIRE, 10, CardType.MONSTER));
|
||||||
|
packages.add(new Package(stack, "Test Package", 100));
|
||||||
|
|
||||||
|
|
||||||
|
System.out.println(user.getTradingDeals().toString());
|
||||||
|
|
||||||
|
user.addTradingDeal(new TradingDeal(user, c1, ElementTyp.FIRE, 10, CardType.MONSTER));
|
||||||
|
System.out.println(user.getTradingDeals().toString());
|
||||||
|
|
||||||
|
|
||||||
|
System.out.println(tradingDeals.toString());
|
||||||
|
assertTrue(user.getTradingDeals().get(0).dealOk(tradingDeals.get(0)));
|
||||||
}
|
}
|
||||||
@Test
|
@Test
|
||||||
void test_doTrade() {
|
void test_doTrade() {
|
||||||
Card cardtest = new Card("Name", 10, ElementTyp.FIRE, CardType.MONSTER);
|
Card cardtest = new Card("Name", 100, ElementTyp.FIRE, CardType.MONSTER);
|
||||||
TradingDeal tradingDealtest = new TradingDeal(user, cardtest, ElementTyp.WATER, 100, CardType.MONSTER);
|
TradingDeal tradingDealtest = new TradingDeal(user, cardtest, ElementTyp.WATER, 100, CardType.MONSTER);
|
||||||
boolean result = user.doTrading(tradingDeal, tradingDealtest);
|
boolean result = user.doTrading(tradingDeal, tradingDealtest);
|
||||||
assertTrue(result);
|
assertTrue(result);
|
||||||
@ -78,27 +91,33 @@ public class StoreTest {
|
|||||||
void test_getTradingDeals() {
|
void test_getTradingDeals() {
|
||||||
ArrayList<TradingDeal> result = user.getTradingDeals();
|
ArrayList<TradingDeal> result = user.getTradingDeals();
|
||||||
ArrayList<TradingDeal> expected = new ArrayList<TradingDeal>();
|
ArrayList<TradingDeal> expected = new ArrayList<TradingDeal>();
|
||||||
|
|
||||||
Card c1 = new Card("Name", 10, ElementTyp.FIRE, CardType.MONSTER);
|
Card c1 = new Card("Name", 10, ElementTyp.FIRE, CardType.MONSTER);
|
||||||
Card c2 = new Card("Name1", 12, ElementTyp.FIRE, CardType.SPELL);
|
Card c2 = new Card("Name1", 12, ElementTyp.FIRE, CardType.SPELL);
|
||||||
Card c3 = new Card("Name2", 13, ElementTyp.WATER, CardType.MONSTER);
|
Card c3 = new Card("Name2", 13, ElementTyp.WATER, CardType.MONSTER);
|
||||||
Card c4 = new Card("Name3", 14, ElementTyp.WATER, CardType.SPELL);
|
Card c4 = new Card("Name3", 14, ElementTyp.WATER, CardType.SPELL);
|
||||||
Card c5 = new Card("Name4", 15, ElementTyp.FIRE, CardType.MONSTER);
|
Card c5 = new Card("Name4", 15, ElementTyp.FIRE, CardType.MONSTER);
|
||||||
Cards deck = new Cards();
|
ArrayList<Card> deckArrList = new ArrayList<Card>();
|
||||||
Cards stack = new Cards();
|
ArrayList<Card> stackArrList = new ArrayList<Card>();
|
||||||
deck.addCard(c1);
|
deckArrList.add(c1);
|
||||||
deck.addCard(c2);
|
deckArrList.add(c2);
|
||||||
stack.addCard(c3);
|
stackArrList.add(c3);
|
||||||
stack.addCard(c4);
|
stackArrList.add(c4);
|
||||||
stack.addCard(c5);
|
stackArrList.add(c5);
|
||||||
TradingDeal vonDB = new TradingDeal(new User(new Credentials("username", "passwort"), "Name", "Nachname", "Email", new Stack(stack, deck), new Coins(1000)), c1, ElementTyp.FIRE, 10, CardType.SPELL);
|
Cards deck = new Cards(deckArrList);
|
||||||
expected.add(vonDB);
|
Cards stack = new Cards(stackArrList);
|
||||||
expected.add(tradingDeal);
|
User user = new User(new Credentials("username", "passwort"), "Name", "Nachname", "Email", new Stack(stack, deck), new Coins(1000));
|
||||||
assertTrue(result.equals(expected));
|
ArrayList<TradingDeal> tradingDeals = new ArrayList<TradingDeal>();
|
||||||
|
ArrayList<Package> packages = new ArrayList<Package>();
|
||||||
|
tradingDeals.add(new TradingDeal(user, c1, ElementTyp.FIRE, 10, CardType.MONSTER));
|
||||||
|
packages.add(new Package(stack, "Test Package", 100));
|
||||||
|
|
||||||
|
assertTrue(result.get(0).dealOk(new TradingDeal(user, c1, ElementTyp.FIRE, 10, CardType.MONSTER)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void test_getPossibleTradingDeals() {
|
void test_getPossibleTradingDeals() {
|
||||||
Card testCard = new Card("Test", 15, ElementTyp.FIRE, CardType.SPELL);
|
Card testCard = new Card("Test", 10, ElementTyp.FIRE, CardType.MONSTER);
|
||||||
ArrayList<TradingDeal> result = user.getPossibleTradingDeals(testCard);
|
ArrayList<TradingDeal> result = user.getPossibleTradingDeals(testCard);
|
||||||
ArrayList<TradingDeal> expected = new ArrayList<TradingDeal>();
|
ArrayList<TradingDeal> expected = new ArrayList<TradingDeal>();
|
||||||
Card c1 = new Card("Name", 10, ElementTyp.FIRE, CardType.MONSTER);
|
Card c1 = new Card("Name", 10, ElementTyp.FIRE, CardType.MONSTER);
|
||||||
@ -106,15 +125,19 @@ public class StoreTest {
|
|||||||
Card c3 = new Card("Name2", 13, ElementTyp.WATER, CardType.MONSTER);
|
Card c3 = new Card("Name2", 13, ElementTyp.WATER, CardType.MONSTER);
|
||||||
Card c4 = new Card("Name3", 14, ElementTyp.WATER, CardType.SPELL);
|
Card c4 = new Card("Name3", 14, ElementTyp.WATER, CardType.SPELL);
|
||||||
Card c5 = new Card("Name4", 15, ElementTyp.FIRE, CardType.MONSTER);
|
Card c5 = new Card("Name4", 15, ElementTyp.FIRE, CardType.MONSTER);
|
||||||
Cards deck = new Cards();
|
ArrayList<Card> deckArrList = new ArrayList<Card>();
|
||||||
Cards stack = new Cards();
|
ArrayList<Card> stackArrList = new ArrayList<Card>();
|
||||||
deck.addCard(c1);
|
deckArrList.add(c1);
|
||||||
deck.addCard(c2);
|
deckArrList.add(c2);
|
||||||
stack.addCard(c3);
|
stackArrList.add(c3);
|
||||||
stack.addCard(c4);
|
stackArrList.add(c4);
|
||||||
stack.addCard(c5);
|
stackArrList.add(c5);
|
||||||
TradingDeal vonDB = new TradingDeal(new User(new Credentials("username", "passwort"), "Name", "Nachname", "Email", new Stack(stack, deck), new Coins(1000)), c1, ElementTyp.FIRE, 10, CardType.SPELL);
|
Cards deck = new Cards(deckArrList);
|
||||||
|
Cards stack = new Cards(stackArrList);
|
||||||
|
TradingDeal vonDB = new TradingDeal(new User(new Credentials("username", "passwort"), "DerName", "Nachname", "Email", new Stack(stack, deck), new Coins(1000)), c1, ElementTyp.FIRE, 10, CardType.SPELL);
|
||||||
expected.add(vonDB);
|
expected.add(vonDB);
|
||||||
assertTrue(result.equals(expected));
|
System.out.println(result.get(0).getCardToTrade().getName());
|
||||||
|
System.out.println(expected.get(0).getCardToTrade().getName());
|
||||||
|
assertTrue(result.get(0).getCardToTrade().equals(expected.get(0).getCardToTrade()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -41,17 +41,17 @@ public class UserTest {
|
|||||||
@Test
|
@Test
|
||||||
public void test_getName() {
|
public void test_getName() {
|
||||||
String result = user.getName();
|
String result = user.getName();
|
||||||
assertTrue(result != "name");
|
assertTrue(result.equals("name"));
|
||||||
}
|
}
|
||||||
@Test
|
@Test
|
||||||
public void test_getNachname() {
|
public void test_getNachname() {
|
||||||
String result = user.getNachname();
|
String result = user.getNachname();
|
||||||
assertTrue(result != "nachname");
|
assertTrue(result.equals("nachname"));
|
||||||
}
|
}
|
||||||
@Test
|
@Test
|
||||||
public void test_getEmail() {
|
public void test_getEmail() {
|
||||||
String result = user.getEmail();
|
String result = user.getEmail();
|
||||||
assertTrue(result != "email");
|
assertTrue(result.equals("email"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -59,21 +59,21 @@ public class UserTest {
|
|||||||
String newstring = "new";
|
String newstring = "new";
|
||||||
user.setName(newstring);
|
user.setName(newstring);
|
||||||
String result = user.getName();
|
String result = user.getName();
|
||||||
assertTrue(result != newstring);
|
assertTrue(result.equals(newstring));
|
||||||
}
|
}
|
||||||
@Test
|
@Test
|
||||||
public void test_setNachname() {
|
public void test_setNachname() {
|
||||||
String newstring = "new";
|
String newstring = "new";
|
||||||
user.setNachname(newstring);
|
user.setNachname(newstring);
|
||||||
String result = user.getNachname();
|
String result = user.getNachname();
|
||||||
assertTrue(result != newstring);
|
assertTrue(result.equals(newstring));
|
||||||
}
|
}
|
||||||
@Test
|
@Test
|
||||||
public void test_setEmail() {
|
public void test_setEmail() {
|
||||||
String newstring = "new";
|
String newstring = "new";
|
||||||
user.setEmail(newstring);
|
user.setEmail(newstring);
|
||||||
String result = user.getEmail();
|
String result = user.getEmail();
|
||||||
assertTrue(result != newstring);
|
assertTrue(result.equals(newstring));
|
||||||
}
|
}
|
||||||
@Test
|
@Test
|
||||||
public void test_buyPackage(){
|
public void test_buyPackage(){
|
||||||
|
Loading…
x
Reference in New Issue
Block a user