public void CastRoleTest() { User user = new User("agent"); bool expected = true; bool actual = user.Login("agent"); Assert.AreEqual(expected, actual); user = user.Find(); User target = (User)user; if (target is Agent) Assert.IsTrue(true); else Assert.IsTrue(false); }
public void ValidateTest() { User user = new User(); user.Validate(); bool expected = false; bool actual = (user.Message.Length > 0) ? false : true; Assert.AreEqual(expected, actual); }
public void LoginPassTest() { User user = new User("agent"); bool expected = true; bool actual = user.Login("agent"); Assert.AreEqual(expected, actual); }
public void LoginFailTest() { User user = new User("A999"); bool expected = false; bool actual = user.Login("W002"); Assert.AreEqual(expected, actual); }
public void IsExistTest() { User user = new User(); user.Code = "W002"; bool expected = true; bool actual = user.IsExist; Assert.AreEqual(expected, actual); }
public List<User> GetAdmin() { List<User> result = new List<User>(); using (DbConnection connection = factory.CreateConnection()) { connection.ConnectionString = connectionString; connection.Open(); using (DbCommand command = connection.CreateCommand()) { command.CommandType = System.Data.CommandType.Text; command.CommandText = "SELECT * FROM Users WHERE Type = 0;"; using (DbDataReader reader = command.ExecuteReader()) { while (reader.Read()) { User user = new User(); user.Id = Convert.ToInt32(reader["Id"]); user.Code = reader["Code"].ToString(); user.Name = reader["Name"].ToString(); user.Password = reader["Password"].ToString(); user.Email = reader["Email"].ToString(); user.Phone = reader["Phone"].ToString(); user.Remarks = reader["Remarks"].ToString(); user.Uri = reader["Uri"].ToString(); if (reader["AddressId"] != DBNull.Value) { int addressId = Convert.ToInt32(reader["AddressId"]); if (addressId > 0) user.Address = new Address(addressId); } result.Add(user); } } } connection.Close(); }//end return result; }