/* $Id: OutfitActionTest.java,v 1.11 2010/09/19 02:38:49 nhnb Exp $ */
/***************************************************************************
* (C) Copyright 2003-2010 - Stendhal *
***************************************************************************
***************************************************************************
* *
* 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. *
* *
***************************************************************************/
package games.stendhal.server.actions;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import games.stendhal.server.entity.player.Player;
import marauroa.common.game.RPAction;
import org.junit.BeforeClass;
import org.junit.Test;
import utilities.PlayerTestHelper;
public class OutfitActionTest {
@BeforeClass
public static void setUpBeforeClass() throws Exception {
}
/**
* Tests for onWrongAction.
*/
@Test
public void testOnWrongAction() {
final OutfitAction oa = new OutfitAction();
final Player player = PlayerTestHelper.createPlayer("player");
final RPAction action = new RPAction();
oa.onAction(player, action);
assertTrue("no exception thrown", true);
}
/**
* Tests for onActionWrongValue.
*/
@Test(expected = NumberFormatException.class)
public void testOnActionWrongValue() {
final OutfitAction oa = new OutfitAction();
final Player player = PlayerTestHelper.createPlayer("player");
final RPAction action = new RPAction();
action.put("value", "schnick");
oa.onAction(player, action);
}
/**
* Tests for onAction.
*/
@Test
public void testOnAction() {
final OutfitAction oa = new OutfitAction();
final Player player = PlayerTestHelper.createPlayer("player");
final RPAction action = new RPAction();
assertNotNull(player.get("outfit"));
action.put("value", 1);
oa.onAction(player, action);
assertTrue(player.has("outfit"));
assertEquals("1", player.get("outfit"));
action.put("value", 51515151);
oa.onAction(player, action);
assertTrue(player.has("outfit"));
assertEquals("invalid player outfit", "1", player.get("outfit"));
}
}