public void UserCreationTest()
 {
     UserCreationMessage x = new UserCreationMessage();
     UserCreationMessage y = new UserCreationMessage(x.getMessageString());
     Assert.AreEqual(x.FirstName,y.FirstName);
     Assert.AreEqual(x.PassWord, y.PassWord);
     Assert.AreEqual(x.LastName, y.LastName);
     Assert.AreEqual(x.UserName, y.UserName);
     Assert.AreEqual(x.ReturnMessage, y.ReturnMessage);
 }
    public string handleUserCreation(string message)
    {
        SqlDataReader dr = null;
        messageSpecs.UserCreationMessage userCreationMsg = new messageSpecs.UserCreationMessage(message);
        userCreationMsg.ReturnMessage = "Failure creating account, Please try again later";
        try
        {
            const string chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
            var random = new Random();
            string pass = new string(Enumerable.Repeat(chars, 10)
              .Select(s => s[random.Next(s.Length)]).ToArray());

            userCreationMsg.PassWord = pass;

            string encryptpass = encrypt(userCreationMsg.PassWord);

            dr = mySql.getDataReader(string.Format("EXEC createUser @EmailAddress = '{0}' ,@UserName = '******',@FirstName = '{2}',@LastName = '{3}',@PassWord = '******',@EncryptPassword = '******'",
                userCreationMsg.EmailAddress,
                userCreationMsg.UserName,
                userCreationMsg.FirstName,
                userCreationMsg.LastName,
                userCreationMsg.PassWord,
                encryptpass));

            while (dr.Read())
            {
                userCreationMsg.Verified = (bool)dr[0];
                userCreationMsg.ReturnMessage = (string)dr[1];
            }
        }
        catch
        {

        }
        finally
        {
            if (dr != null)
            {
                dr.Close();
            }

        }
        return userCreationMsg.getMessageString();
    }
        public void CreateUser()
        {
            SocketHandler.SocketServer mySockets = new SocketHandler.SocketServer(0, 1000);
            SocketHandler.SocketClient clientSocket = null;
            mySockets.Init();
            mySockets.Start(new System.Net.IPEndPoint(System.Net.IPAddress.Parse("127.0.0.1"), 20000));
            clientSocket = new SocketHandler.SocketClient("127.0.0.1", 20000, false, ((char)2).ToString(), ((char)3).ToString());

            messageSpecs.UserCreationMessage myCreationMessage = new messageSpecs.UserCreationMessage();
            myCreationMessage.EmailAddress = "*****@*****.**";
            myCreationMessage.UserName = "******";
            myCreationMessage.FirstName = "Cody";
            myCreationMessage.LastName = "Eidsness";
            clientSocket.Send(myCreationMessage.getMessageString());

            for(int i = 1;i<=5;i++)
            {
                System.Threading.Thread.Sleep(1000);
                while (clientSocket.messageQueue.Count > 0)
                {
                    if (clientSocket.messageQueue.Dequeue().Substring(0, 5) == UserCreationMessage.CreateUserMessageType)
                    {
                        return;
                    }
                }
            }
            Assert.Fail("Never got login message back");
        }