Package scotlandyard

Source Code of scotlandyard.UserTest

package scotlandyard;

import junit.framework.Assert;

import org.junit.BeforeClass;
import org.junit.Test;

import scotlandyard.engine.impl.Engine;
import scotlandyard.servlets.beans.WebUserBean;
import scotlandyard.servlets.web.reset_game_engine;


public class UserTest {

  String mrxEmail = "something";
  String detectiveEmail = "something else";

  String mrxName = "random";
  String detectiveName = "other random";

  String mrxHash = Engine.md5(mrxEmail);
  String detectiveHash = Engine.md5(detectiveEmail);
  String gameId = "New Game";

  public UserTest() throws Exception{
    // TODO Auto-generated constructor stub
  }
 
  @BeforeClass
  public static void beforeClass() throws Exception{
    new WebUserBean();
    new reset_game_engine().processRequest("");
  }

  @Test
  public void testGetHash() throws Exception{
    Engine.instance().login(mrxEmail,mrxName,"0");
    Engine.instance().login(detectiveEmail,detectiveName,"1");
    Assert.assertTrue(Engine.instance().getUser(mrxHash).getHash().equals(mrxHash));
    Assert.assertTrue(Engine.instance().getUser(detectiveHash).getHash().equals(detectiveHash));

  }

  @Test
  public void testGetEmail(){
    Assert.assertTrue(Engine.instance().getUser(mrxHash).getEmail().equals(mrxEmail));
    Assert.assertTrue(Engine.instance().getUser(detectiveHash).getEmail().equals(detectiveEmail));
  }

  @Test
  public void testGetName(){
    Assert.assertTrue(Engine.instance().getUser(mrxHash).getName().equals(mrxName));
    Assert.assertTrue(Engine.instance().getUser(detectiveHash).getName().equals(detectiveName));
  }

  @Test
  public void testGetIcon(){
    Assert.assertNotNull(Engine.instance().getUser(detectiveHash).getIcon());
  }

  @Test
  public void testGetSID(){
    Assert.assertTrue(Engine.instance().getUser(mrxHash).getSID().equals("0"));
    Assert.assertTrue(Engine.instance().getUser(detectiveHash).getSID().equals("1"));
  }

  @Test
  public void testSetIcon(){
    Engine.instance().getUser(mrxHash).setIcon("x2.gif");
    Engine.instance().getUser(detectiveHash).setIcon("d2.gif");
    Assert.assertTrue(Engine.instance().getUser(mrxHash).getIcon().equals("x2.gif"));
    Assert.assertTrue(Engine.instance().getUser(detectiveHash).getIcon().equals("d2.gif"));
  }

}
TOP

Related Classes of scotlandyard.UserTest

TOP
Copyright © 2018 www.massapi.com. 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.