public void LoginRegisterTests()
{
ServerController sc = new ServerController();
Assert.AreEqual(Result.USER_NOT_FOUND, sc.Login("user1", "123456"));//login before register
Assert.AreEqual(Result.SECURITY_ERROR, sc.Register("alice", "123456"));
//login tests
for (int i = 0; i < 100; i++)
{
// try to register twice with same userName
Assert.AreEqual(Result.SECURITY_ERROR, sc.Register("alice" + i, "123456"));
Assert.AreEqual(Result.SECURITY_ERROR, sc.Register("alice" + i, "123456"));
//failed: try to login twice with same userName return true , should return false.
Assert.AreEqual(Result.OK, sc.Login("alice" + i, "123456"));
//Assert.IsFalse(sc.Login("alice" + i, "123456"));
Assert.AreEqual(Result.USER_NOT_FOUND, sc.Login("bob" + i, "123456"));//try to login with bad unknown user
Assert.AreEqual(Result.SECURITY_ERROR, sc.Login("alice" + i, "123456" + i));//try to login with bad password
}
}