Package scotlandyard

Source Code of scotlandyard.EngineTest

package scotlandyard;

import junit.framework.Assert;

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

import scotlandyard.engine.impl.Engine;
import scotlandyard.engine.spec.IUser;
import scotlandyard.servlets.beans.WebUserBean;


public class EngineTest {

  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 EngineTest() throws Exception{
    // TODO Auto-generated constructor stub
  }
 
  @BeforeClass
  public static void beforeClass() throws Exception{
    new WebUserBean();
  }
 
  @Test
  public void testLogin() throws Exception{
    IUser mrx = Engine.instance().login(mrxEmail, mrxName,"0");
    IUser detective = Engine.instance().login(detectiveEmail, detectiveName,"1");
    Assert.assertTrue(Engine.instance().getUser(mrxHash).equals(mrx));
    Assert.assertTrue(Engine.instance().getUser(detectiveHash).equals(detective));
    Assert.assertFalse(Engine.instance().getUser(mrxHash).equals(detective));
    Assert.assertFalse(Engine.instance().getUser(detectiveHash).equals(mrx));
  }

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

  @Test
  public void testLogout() throws Exception
  {
    Engine.instance().logout(mrxHash);
    Assert.assertTrue(Engine.instance().users.size() == 1);
    Engine.instance().logout(detectiveHash);
    Assert.assertTrue(Engine.instance().users.isEmpty());
  }

}
TOP

Related Classes of scotlandyard.EngineTest

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.