From: Sean B. <sbr...@ya...> - 2007-07-06 05:04:37
|
This has been committed with revision, http://triplea.svn.sourceforge.net/viewvc/triplea?view=rev&revision=1828 I removed some of the checks as it is hard to tell what is being tested, and re-organized a bit. Ideally we should have lots of small simple tests, rather than big tests. It makes it easy to see what is being tested and to see what is broken. Thanks, Sean --- Kevin Comcowich <com...@ya...> wrote: > Here's the patch for the J-Unit test of the Japan > turn > one in Pacific. > > I was a little bit confused by the implementation of > ScriptedRandomSource with more than one die roll and > I > don't have the time right now to figure it out, and > so > I just did a down and dirty test with single unit > rolls. I hope that's OK. > > I haven't looked at your bug report but will > hopefully > take a look in the next couple of days. > > Thanks, > Kevin > > > > > --- Sean Bridges <sbr...@ya...> wrote: > > > Thanks, this has been committed with revision, > > > > > http://triplea.svn.sourceforge.net/viewvc/triplea?view=rev&revision=1814 > > > > Could you add a unit test for this as well. Make > a > > new test class called PacificTest (look at > > RevisedTest > > for a model). Then look at DiceRollTest to see > how > > to > > add tests for this change. > > > > > > The battle display is still not quite right, so I > > opened a bug, > > > > > http://sourceforge.net/tracker/index.php?func=detail&aid=1746101&group_id=44492&atid=439737 > > > > Thanks, > > > > Sean > > > > --- Kevin Comcowich <com...@ya...> wrote: > > > > > I've made changes to DiceRoll.java to account > for > > > Japan's special turn one attack in Pacific. If > > you > > > have questions or comments, please feel free to > > > contact me via this email addy or comradekev at > > > users.sourceforge.net (I think I've got that one > > > figured out). > > > > > > Thanks, > > > Kevin > > > > > > > > > > > > > > > > > > ____________________________________________________________________________________ > > > Building a website is a piece of cake. Yahoo! > > Small > > > Business gives you all the tools to get online. > > > http://smallbusiness.yahoo.com/webhosting > > Index: > > C:/Program Files/Eclipse > > > > > > SDK/eclipse/work/triplea/src/games/strategy/triplea/delegate/DiceRoll.java > > > > > > =================================================================== > > > --- C:/Program Files/Eclipse > > > > > > SDK/eclipse/work/triplea/src/games/strategy/triplea/delegate/DiceRoll.java > > > (revision 1792) > > > +++ C:/Program Files/Eclipse > > > > > > SDK/eclipse/work/triplea/src/games/strategy/triplea/delegate/DiceRoll.java > > > (working copy) > > > @@ -261,7 +261,20 @@ > > > { > > > int strength; > > > if (defending) > > > - strength = > > > ua.getDefense(current.getOwner()); > > > + //If it's > Pacific_Edition > > > and Japan's turn one, all but Chinese defend at > a > > 1 > > > + { > > > + if > > > > > > (bridge.getPlayerID().getData().getProperties().get(Constants.PACIFIC_EDITION, > > > false) > > > + && > > > > > > bridge.getPlayerID().getData().getSequence().getRound() > > > == 1 > > > + && > > > bridge.getStepName().equals("japaneseBattle") > > > + && > > > !player.getName().equals("Chinese")) > > > + { > > > + strength = 1; > > > + } > > > + else > > > + { > > > + strength = > > > ua.getDefense(current.getOwner()); > > > + } > > > + } > > > else > > > { > > > strength = > > > ua.getAttack(current.getOwner()); > > > > > > > ------------------------------------------------------------------------- > > > This SF.net email is sponsored by DB2 Express > > > Download DB2 Express C - the FREE version of DB2 > > > express and take > > > control of your XML. No limits. Just data. Click > > to > > > get it now. > > > http://sourceforge.net/powerbar/db2/> > > _______________________________________________ > > > Triplea-developers mailing list > > > Tri...@li... > > > > > > https://lists.sourceforge.net/lists/listinfo/triplea-developers > > > > > > > > > > > > > > ____________________________________________________________________________________ > > Fussy? Opinionated? Impossible to please? Perfect. > > > Join Yahoo!'s user panel and lay it on us. > > > http://surveylink.yahoo.com/gmrs/yahoo_panel_invite.asp?a=7 > > > > > > > > > > > ____________________________________________________________________________________ > Never miss an email again! > Yahoo! Toolbar alerts you the instant new Mail > arrives. > http://tools.search.yahoo.com/toolbar/features/mail/> Index: C:/Program Files/Eclipse > SDK/eclipse/work/triplea/test/games/strategy/triplea/delegate/PacificTest.java > =================================================================== > --- C:/Program Files/Eclipse > SDK/eclipse/work/triplea/test/games/strategy/triplea/delegate/PacificTest.java > (revision 0) > +++ C:/Program Files/Eclipse > SDK/eclipse/work/triplea/test/games/strategy/triplea/delegate/PacificTest.java > (revision 0) > @@ -0,0 +1,559 @@ > +/* > + * This program is free software; you can > redistribute it and/or modify > + * it under the terms of the GNU General Public > License as published by > + * the Free Software Foundation; either version 2 > of the License, or > + * (at your option) any later version. > + * This program is distributed in the hope that it > will be useful, > + * but WITHOUT ANY WARRANTY; without even the > implied warranty of > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR > PURPOSE. See the > + * GNU General Public License for more details. > + * You should have received a copy of the GNU > General Public License > + * along with this program; if not, write to the > Free Software > + * Foundation, Inc., 59 Temple Place, Suite 330, > Boston, MA 02111-1307 USA > + */ > + > +package games.strategy.triplea.delegate; > + > +import java.io.*; > +import java.lang.reflect.*; > +import java.util.List; > + > +import junit.framework.TestCase; > + > +import games.strategy.engine.data.*; > +import games.strategy.engine.display.IDisplay; > +import games.strategy.engine.framework.GameRunner; > +import > games.strategy.engine.lobby.server.GameDescription; > +import > games.strategy.engine.random.ScriptedRandomSource; > +import games.strategy.triplea.Constants; > +import > games.strategy.triplea.attatchments.UnitAttachment; > +import > games.strategy.triplea.player.ITripleaPlayer; > +import > games.strategy.triplea.ui.display.DummyDisplay; > +import games.strategy.util.CompositeMatchAnd; > + > +public class PacificTest extends TestCase > +{ > + > + private GameData m_data; > + > + @Override > + protected void setUp() throws Exception > + { > + File gameRoot = > GameRunner.getRootFolder(); > + File gamesFolder = new File(gameRoot, > "games"); > + File pacific = new File(gamesFolder, > "pacific_incomplete.xml"); > + > + if(!pacific.exists()) > + throw new > IllegalStateException("pacific game does not > exist"); > + > + InputStream input = new > BufferedInputStream(new FileInputStream(pacific)); > + > + try > + { > + m_data = (new > GameParser()).parse(input); > + } > + finally > + { > + input.close(); > + } > + } > + > + @Override > + protected void tearDown() throws Exception > + { > + m_data = null; > + } > + > + private ITripleaPlayer getDummyPlayer() > + { > + InvocationHandler handler = new > InvocationHandler() > + { > + public Object invoke(Object proxy, > Method method, Object[] args) throws Throwable > + { > + return null; > + } > + }; > + > + return (ITripleaPlayer) > Proxy.newProxyInstance(Thread.currentThread().getContextClassLoader(), > new Class[] {ITripleaPlayer.class}, handler ); > + > + > + } > + > + public void testJapanFirstPacificTurn() > + { > + final GameDescription m_gameDescription; > + > + //Define unit types to be tested > + UnitType infantry = > m_data.getUnitTypeList().getUnitType("infantry"); > > + UnitType armor = > m_data.getUnitTypeList().getUnitType("armour"); > > + UnitType artillery = > m_data.getUnitTypeList().getUnitType("artillery"); > > + UnitType marine = > m_data.getUnitTypeList().getUnitType("marine"); > + UnitType fighter = > m_data.getUnitTypeList().getUnitType("fighter"); > > + UnitType bomber = > m_data.getUnitTypeList().getUnitType("bomber"); > + UnitType sub = > m_data.getUnitTypeList().getUnitType("submarine"); > + UnitType destroyer = > m_data.getUnitTypeList().getUnitType("destroyer"); > + UnitType carrier = > m_data.getUnitTypeList().getUnitType("carrier"); > + UnitType battleship = > m_data.getUnitTypeList().getUnitType("battleship"); > + UnitType transport = > m_data.getUnitTypeList().getUnitType("transport"); > + > + //Define defending players > + PlayerID americans = > m_data.getPlayerList().getPlayerID("Americans"); > + PlayerID chinese = > m_data.getPlayerList().getPlayerID("Chinese"); > + PlayerID british = > m_data.getPlayerList().getPlayerID("British"); > + > + //Create mock battle area > + Territory queensland = > m_data.getMap().getTerritory("Queensland"); > + MockBattle battle = new > MockBattle(queensland); > + > + TestDelegateBridge bridge = new > TestDelegateBridge(m_data, americans, (IDisplay) new > DummyDisplay()); > + > + /* > + if > (bridge.getPlayerID().getData().getProperties().get(Constants.PACIFIC_EDITION, > false) > + && > bridge.getPlayerID().getData().getSequence().getRound() > == 1 > + && > bridge.getStepName().equals("japaneseBattle") > + && > !player.getName().equals("Chinese")).... > + */ > + //Set the stepname so that it fails the > check above in DiceRoll.java > + bridge.setStepName("NOTjapaneseBattle"); > + > + /* //Check settings > + Boolean firstCheck = > bridge.getPlayerID().getData().getProperties().get(Constants.PACIFIC_EDITION, > false); > + Boolean secCheck = > (bridge.getPlayerID().getData().getSequence().getRound() > == 1); > + Boolean thrCheck = > bridge.getStepName().equals("japaneseBattle"); > + Boolean fortCheck = > !bridge.getPlayerID().getName().equals("Chinese"); > + > + String gameName = m_data.getGameName(); > + > + int round = > bridge.getPlayerID().getData().getSequence().getRound(); > + String player = > bridge.getPlayerID().toString(); > + */ > === message truncated === ____________________________________________________________________________________ 8:00? 8:25? 8:40? Find a flick in no time with the Yahoo! Search movie showtime shortcut. http://tools.search.yahoo.com/shortcuts/#news |