public ActionResult Create(UserInputModel userInputModel) { if (_session.Query<User>().Any(x => x.Username == userInputModel.Username)) { ModelState.AddModelError("Username", "Username is already in use"); } if (ModelState.IsValid) { var company = new Company(userInputModel.Username + " Co."); _session.Store(company); var user = new User( userInputModel.Username, Encryption.HashPassword(userInputModel.Password), new string[0], company); _session.Store(user); _authenticator.SetCookie(user.Id, false, user.Roles.ToArray()); return RedirectToAction("Index", "Home"); } return View("New", userInputModel); }
public void Constructor_Correctly_Initializes_Object_State() { // Arrange const string description = "companyDescription"; // Act Company company = new Company(description); // Assert company.ShouldBeEquivalentTo(new { Id = (string)null, Description = description }); }