public void WithViewModelRendersWithoutExceptions() { var view = new Register(); var viewModel = new RegisterViewModel { ConfirmPassword = "******", Password = "******", Email = "incorrect" }; var html = view.RenderAsHtml(viewModel); }
public ActionResult Register(RegisterViewModel model) { Contract.Requires<InvalidOperationException>(this.ClientService != null); Contract.Requires<InvalidOperationException>(this.SessionPersister != null); Contract.Requires<ArgumentNullException>(model != null, "model"); if (this.SessionPersister.HasSession) { throw new InvalidOperationException("The user is already logged in."); } if (this.ModelState.IsValid) { this.ClientService.CreateUser(model.Email, model.Password, model.ParentUserId); this.SessionPersister.SessionId = this.ClientService.CreateSession(model.Email, model.Password); return this.RedirectToAction(string.Empty, "Account"); } return this.View(model); }