Package games.stendhal.client

Examples of games.stendhal.client.MockClientUI


   *
   * @throws Exception
   */
  @BeforeClass
  public static void buildWorld() throws Exception {
    new MockClientUI();
  }
View Full Code Here


  /**
   * Tests for noMoney.
   */
  @Test
  public void testNoMoney() {
    final MockClientUI clientUI = new MockClientUI();
    final DropAction action = new DropAction();

    createPlayer();

    // issue "/drop money"
    assertTrue(action.execute(new String[]{"money"}, ""));
    assertEquals("You don't have any money", clientUI.getEventBuffer());
  }
View Full Code Here

  /**
   * Tests for invalidAmount.
   */
  @Test
  public void testInvalidAmount() {
    final MockClientUI clientUI = new MockClientUI();
    final DropAction action = new DropAction();

    createPlayer();

    // issue "/drop 85x money"
    assertTrue(action.execute(new String[]{"85x"}, "money"));
    assertEquals("Invalid quantity: 85x", clientUI.getEventBuffer());
  }
View Full Code Here

   * Tests for dropSingle.
   */
  @Test
  public void testDropSingle() {
    // create client UI
    final MockClientUI clientUI = new MockClientUI();

    // create client
    new MockStendhalClient() {
      @Override
      public void send(final RPAction action) {
        client = null;
        assertEquals("drop", action.get("type"));
        assertEquals(USER_ID, action.getInt("baseobject"));
        assertEquals(0, action.getInt("x"));
        assertEquals(0, action.getInt("y"));
        assertEquals("bag", action.get("baseslot"));
        assertEquals(1, action.getInt("quantity"));
        assertEquals(MONEY_ID, action.getInt("baseitem"));
      }
    };

    // create a player and give him some money
    final RPObject player = createPlayer();
    player.getSlot("bag").addPreservingId(createItem("money", MONEY_ID, 100));

    // issue "/drop money"
    final DropAction action = new DropAction();
    assertTrue(action.execute(new String[]{"money"}, ""));
    assertEquals("", clientUI.getEventBuffer());
  }
View Full Code Here

   * Tests for dropMultiple.
   */
  @Test
  public void testDropMultiple() {
    // create client UI
    final MockClientUI clientUI = new MockClientUI();

    // create client
    new MockStendhalClient() {
      @Override
      public void send(final RPAction action) {
        client = null;
        assertEquals("drop", action.get("type"));
        assertEquals(USER_ID, action.getInt("baseobject"));
        assertEquals(0, action.getInt("x"));
        assertEquals(0, action.getInt("y"));
        assertEquals("bag", action.get("baseslot"));
        assertEquals(50, action.getInt("quantity"));
        assertEquals(MONEY_ID, action.getInt("baseitem"));
      }
    };

    // create a player and give him some money
    final RPObject player = createPlayer();
    player.getSlot("bag").addPreservingId(createItem("money", MONEY_ID, 100));

    // issue "/drop 50 money"
    final DropAction action = new DropAction();
    assertTrue(action.execute(new String[]{"50"}, "money"));
    assertEquals("", clientUI.getEventBuffer());
  }
View Full Code Here

   * Tests for spaceHandling.
   */
  @Test
  public void testSpaceHandling() {
    // create client UI
    final MockClientUI clientUI = new MockClientUI();

    // create client
    new MockStendhalClient() {
      @Override
      public void send(final RPAction action) {
        client = null;
        assertEquals("drop", action.get("type"));
        assertEquals(USER_ID, action.getInt("baseobject"));
        assertEquals(0, action.getInt("x"));
        assertEquals(0, action.getInt("y"));
        assertEquals("bag", action.get("baseslot"));
        assertEquals(1, action.getInt("quantity"));
        assertEquals(SILVER_SWORD_ID, action.getInt("baseitem"));
      }
    };

    // create a player and give him some money
    final RPObject player = createPlayer();
    player.getSlot("bag").addPreservingId(createItem("silver sword", SILVER_SWORD_ID, 1));

    // issue "/drop money"
    final DropAction action = new DropAction();
    assertTrue(action.execute(new String[]{"silver"}, "sword"));
    assertEquals("", clientUI.getEventBuffer());
  }
View Full Code Here

   * Tests for execute.
   */
  @Test
  public void testExecute() {
    // create client UI
    final MockClientUI clientUI = new MockClientUI();

    // create client
    new MockStendhalClient() {
      @Override
      public void send(final RPAction action) {
        assertEquals("summonat", action.get("type"));
        assertEquals("player", action.get("target"));
        assertEquals("bag", action.get("slot"));
        assertEquals(5, action.getInt("amount"));
        assertEquals("money", action.get("item"));
      }
    };

    // issue "/summonat bag 5 money"
    final SummonAtAction action = new SummonAtAction();
    assertTrue(action.execute(new String[]{"player", "bag", "5"}, "money"));
    assertEquals("", clientUI.getEventBuffer());
  }
View Full Code Here

   * Tests for spaceHandling.
   */
  @Test
  public void testSpaceHandling() {
    // create client UI
    final MockClientUI clientUI = new MockClientUI();

    // create client
    new MockStendhalClient() {
      @Override
      public void send(final RPAction action) {
        assertEquals("summonat", action.get("type"));
        assertEquals("player", action.get("target"));
        assertEquals("bag", action.get("slot"));
        assertEquals(1, action.getInt("amount"));
        assertEquals("silver sword", action.get("item"));
      }
    };

    // issue "/summonat bag silver sword"
    final SummonAtAction action = new SummonAtAction();
    assertTrue(action.execute(new String[]{"player", "bag", "silver"}, "sword"));
    assertEquals("", clientUI.getEventBuffer());
  }
View Full Code Here

   * Tests for fromChatline.
   */
  @Test
  public void testFromChatline() throws Exception {
    // create client UI
    @SuppressWarnings("unused")
    final MockClientUI clientUI = new MockClientUI();

    // create client
    new MockStendhalClient() {
      @Override
      public void send(final RPAction action) {
View Full Code Here

TOP

Related Classes of games.stendhal.client.MockClientUI

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.