public EmRegisterStatus Register(Account newAccount)
 {
     if (this.Db.Count<Account>(c => c.UserName == newAccount.UserName) > 0)
     {
         return EmRegisterStatus.AccountExist;
     }
     else
     {
         try
         {
             this.Db.Insert<Account>(new Account() { UserName = newAccount.UserName, Password = newAccount.Password, DisplayName=newAccount.DisplayName});
             return EmRegisterStatus.Success;
         }
         catch (Exception ex)
         {
             Logger.Error("insert account failed. ", ex);
             return EmRegisterStatus.SysError;
         }
     }
 }
        public void Register()
        {
            var modelSuccess = new RegisterModel()
            {
                DisplayName = "displayname",
                ConfirmPassword = "******",
                Password = "******",
                UserName = "******"
            };
            var modelExists = new RegisterModel()
            {
                DisplayName = "displayname_exists",
                ConfirmPassword = "******",
                Password = "******",
                UserName = "******"
            };

            var modelUserNameError = new RegisterModel()
            {
                DisplayName = "123",
                UserName = "******",
                Password = "******",
                ConfirmPassword = "******"
            };

            var accountSuccess = new Account() { DisplayName = modelSuccess.DisplayName, Password = modelSuccess.Password, UserName = modelSuccess.UserName };
            var accountExists = new Account() { DisplayName = modelExists.DisplayName, Password = modelExists.Password, UserName = modelExists.UserName };

            this._usersManageService.Register(
                Arg.Is<Account>(
                    a => a.DisplayName == accountSuccess.DisplayName && a.Password == accountSuccess.Password
                         && a.UserName == accountSuccess.UserName && a.Id == accountSuccess.Id))
                .Returns(EmRegisterStatus.Success);

            this._usersManageService.Register(Arg.Is<Account>(
                    a => a.DisplayName == accountExists.DisplayName && a.Password == accountExists.Password
                         && a.UserName == accountExists.UserName && a.Id == accountExists.Id)).Returns(EmRegisterStatus.AccountExist);

            this._controller.WithCallTo(c => c.Register(modelSuccess, "/")).ShouldRedirectTo("/");
            this._controller.WithCallTo(c => c.Register(modelExists, "/")).ShouldRenderView("Register");
            this._controller.WithModelErrors().WithCallTo(c => c.Register(modelUserNameError, "/"))
                .ShouldRenderView("Register");
        }