CreateAccountController.CreateAccount C# (CSharp) Method

CreateAccount() public method

public CreateAccount ( ) : void
return void
    public void CreateAccount() {
        if (Username.text.Length == 0 || DisplayName.text.Length == 0 || Password.text.Length == 0) {
            ErrorField.text = "Input fields can not be empty.";
            ErrorField.color = Color.red;
            return;
        }

        Socket s = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
        s.Connect(GlobalSettings.Instance.ServerIp, GlobalSettings.Instance.ServerPort);
        SecurePassword pass = Cryptography.GetSaltHash(Password.text);
        string response = GetResponse(s,
            string.Format("Request:CreateAccount:{0}|{1}|{2}|{3}", Username.text, DisplayName.text, pass.Hash, pass.Salt));
        if (response == null)
            return;
        else {
            Username.text = "";
            DisplayName.text = "";
            Password.text = "";
            ErrorField.text = "Account created successfully.";
            ErrorField.color = Color.green;
        }
    }

Usage Example

コード例 #1
0
        public void CreationSuccesfulStudent()
        {
            string   testAccountType    = "Student";
            string   testLastName       = "Hounnou";
            string   testFirstName      = "Koffi";
            string   testLogin          = "******";
            string   testPwd            = "ffiko";
            string   testMailAdresse    = "*****@*****.**";
            DateTime testEnrollmentDate = DateTime.Now;

            EntityGenerator generator = new EntityGenerator(dbContext);
            Student         student   = generator.CreateStudentForLogin(testLastName, testFirstName, testLogin, testPwd, testMailAdresse, testEnrollmentDate);

            var result        = controllerToTest.CreateAccount(testAccountType, testLastName, testFirstName, testMailAdresse, testLogin, testPwd) as ViewResult;
            var resultStudent = controllerToTest.CreateAccount(testAccountType, testLastName, testFirstName, testMailAdresse, testLogin, testPwd);

            Assert.That(result, Is.Not.Null);
            Assert.That(resultStudent, Is.Not.Null);
            // Assert.That(testLastName, Is.EqualTo(resultStudent.LastName));
            //    Assert.That(expectedFirstName, Is.EqualTo(resultModel.FirstMidName));
        }