mirror of
https://github.com/magefree/mage.git
synced 2025-12-26 05:22:02 -08:00
Dev: clear pom files, fixed wrong test packages and scope, added zip tests;
This commit is contained in:
parent
6f76c3371e
commit
f9beed6a89
15 changed files with 115 additions and 41 deletions
|
|
@ -9,7 +9,6 @@ import mage.abilities.effects.ContinuousEffect;
|
|||
import mage.abilities.effects.ContinuousEffectImpl;
|
||||
import mage.constants.*;
|
||||
import mage.game.Game;
|
||||
import org.junit.Assert;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
|
|
@ -48,13 +47,13 @@ public class ConditionalContinuousEffect extends ContinuousEffectImpl {
|
|||
// checks for compatibility
|
||||
EffectType needType = EffectType.CONTINUOUS;
|
||||
if (effect.getEffectType() != needType) {
|
||||
Assert.fail("ConditionalContinuousEffect supports only " + needType.toString() + " but found " + effect.getEffectType().toString());
|
||||
throw new IllegalArgumentException("ConditionalContinuousEffect supports only " + needType + " but found " + effect.getEffectType().toString());
|
||||
}
|
||||
if (otherwiseEffect != null && otherwiseEffect.getEffectType() != needType) {
|
||||
Assert.fail("ConditionalContinuousEffect supports only " + needType.toString() + " but found " + effect.getEffectType().toString());
|
||||
throw new IllegalArgumentException("ConditionalContinuousEffect supports only " + needType.toString() + " but found " + effect.getEffectType().toString());
|
||||
}
|
||||
if (otherwiseEffect != null && effect.getEffectType() != otherwiseEffect.getEffectType()) {
|
||||
Assert.fail("ConditionalContinuousEffect must be same but found " + effect.getEffectType().toString() + " and " + otherwiseEffect.getEffectType().toString());
|
||||
throw new IllegalArgumentException("ConditionalContinuousEffect must be same but found " + effect.getEffectType().toString() + " and " + otherwiseEffect.getEffectType().toString());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,46 +0,0 @@
|
|||
package mage.cards.decks;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author JayDi85
|
||||
*/
|
||||
public class DeckFormatsTest {
|
||||
|
||||
@Test
|
||||
public void test_FormatsExt() {
|
||||
Map<String, DeckFormats> extList = new HashMap<>();
|
||||
for (DeckFormats df : DeckFormats.values()) {
|
||||
// 1. must be unique
|
||||
if (extList.containsKey(df.getExporter().getDefaultFileExt())) {
|
||||
Assert.fail("Default ext must be unique for each format: " + df.getExporter().getDescription());
|
||||
} else {
|
||||
extList.putIfAbsent(df.getExporter().getDefaultFileExt(), df);
|
||||
}
|
||||
// 2. must work with files
|
||||
String fileName = "C:\\xmage\\deck" + "." + df.getExporter().getDefaultFileExt();
|
||||
Assert.assertTrue("Must support lower ext: " + df.getExporter().getDescription(), DeckFormats.getFormatForExtension(fileName.toLowerCase(Locale.ENGLISH)).isPresent());
|
||||
Assert.assertTrue("Must support upper ext: " + df.getExporter().getDescription(), DeckFormats.getFormatForExtension(fileName.toUpperCase(Locale.ENGLISH)).isPresent());
|
||||
}
|
||||
|
||||
// 3. wrong ext
|
||||
Assert.assertFalse("Must not find empty ext", DeckFormats.getFormatForExtension("deck").isPresent());
|
||||
Assert.assertFalse("Must not find . ext", DeckFormats.getFormatForExtension("deck.").isPresent());
|
||||
Assert.assertFalse("Must not find unknown ext", DeckFormats.getFormatForExtension("deck.xxx").isPresent());
|
||||
|
||||
// 3. double ext
|
||||
String fileName = "C:\\xmage\\deck"
|
||||
+ "." + DeckFormats.XMAGE.getExporter().getDefaultFileExt()
|
||||
+ "." + DeckFormats.MTG_ONLINE.getExporter().getDefaultFileExt();
|
||||
Assert.assertEquals("Must find mtgo", DeckFormats.getFormatForExtension(fileName).get(), DeckFormats.MTG_ONLINE);
|
||||
fileName = "C:\\xmage\\deck"
|
||||
+ "." + DeckFormats.MTG_ONLINE.getExporter().getDefaultFileExt()
|
||||
+ "." + DeckFormats.XMAGE.getExporter().getDefaultFileExt();
|
||||
Assert.assertEquals("Must find xmage", DeckFormats.getFormatForExtension(fileName).get(), DeckFormats.XMAGE);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,40 +0,0 @@
|
|||
package mage.cards.decks.exporter;
|
||||
|
||||
import mage.cards.decks.DeckCardInfo;
|
||||
import mage.cards.decks.DeckCardLists;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
/**
|
||||
* @author JayDi85
|
||||
*/
|
||||
public class MtgArenaDeckExporterTest {
|
||||
|
||||
@Test
|
||||
public void writeDeck() throws IOException {
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
DeckCardLists deck = new DeckCardLists();
|
||||
deck.getCards().add(new DeckCardInfo("Forest", "1", "RNA", 2));
|
||||
deck.getCards().add(new DeckCardInfo("Plains", "2", "RNA", 3));
|
||||
deck.getCards().add(new DeckCardInfo("Plains", "2", "RNA", 5)); // must combine
|
||||
deck.getCards().add(new DeckCardInfo("Mountain", "3", "RNA", 1));
|
||||
deck.getCards().add(new DeckCardInfo("Goblin Chainwhirler", "129", "DOM", 4));
|
||||
deck.getSideboard().add(new DeckCardInfo("Island", "1", "RNA", 2));
|
||||
deck.getSideboard().add(new DeckCardInfo("Island", "1", "RNA", 5)); // must combine
|
||||
deck.getSideboard().add(new DeckCardInfo("Mountain", "2", "RNA", 3));
|
||||
DeckExporter exporter = new MtgArenaDeckExporter();
|
||||
exporter.writeDeck(baos, deck);
|
||||
assertEquals("2 Forest (RNA) 1" + System.lineSeparator() +
|
||||
"8 Plains (RNA) 2" + System.lineSeparator() +
|
||||
"1 Mountain (RNA) 3" + System.lineSeparator() +
|
||||
"4 Goblin Chainwhirler (DAR) 129" + System.lineSeparator() +
|
||||
System.lineSeparator() +
|
||||
"7 Island (RNA) 1" + System.lineSeparator() +
|
||||
"3 Mountain (RNA) 2" + System.lineSeparator(),
|
||||
baos.toString());
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue