public void CreatesNewAccountAndRedirects() { var endpoint = TestableRegisterEndpoint.Build(new Mock<IDocumentSession>().Object); var command = new RegisterCommand(); var continuation = endpoint.Register(command); endpoint.Service.Verify(x => x.CreateNew(command)); continuation.AssertWasRedirectedTo<HomeRequest>(); }
private static RegisterCommand validCommand() { var command = new RegisterCommand { Username = "******", Password = "******", ConfirmPassword = "******", EmailAddress = "*****@*****.**", }; return command; }
public void CreatesStoresAndSetsTheCookie() { var service = TestableUserAccountService.Build(); var command = new RegisterCommand { Username = "******", Password = "******", EmailAddress = "*****@*****.**", Cookies = service.Cookies.Object, HttpContext = service.HttpContext.Object }; var userAccount = service.CreateNew(command); service.Session.Verify(x => x.Store(userAccount, userAccount.DocumentKey)); service.Cookies.Verify(x => x.Set(UserAccount.LoginCookieName, userAccount.DocumentKey)); userAccount.Username.ShouldEqual(command.Username); userAccount.Password.ShouldEqual(command.Password); userAccount.EmailAddress.ShouldEqual(command.EmailAddress); }
public UserAccount CreateNew(RegisterCommand command) { var account = new UserAccount { EmailAddress = command.EmailAddress, EmailHash = createEmailhash(command.EmailAddress), Password = command.Password, Username = command.Username }; account.Roles.Add(UserAccount.BasicUserRole); _session.Store(account, UserAccount.Key(account.Username)); Login(account); return account; }
public void CreatesEmailHash() { var service = TestableUserAccountService.Build(); var command = new RegisterCommand { Username = "******", Password = "******", EmailAddress = "*****@*****.**", Cookies = service.Cookies.Object, HttpContext = service.HttpContext.Object }; var userAccount = service.CreateNew(command); using (var md5 = MD5.Create()) { var data = md5.ComputeHash(Encoding.UTF8.GetBytes(command.EmailAddress)); var expectedHash = new StringBuilder(); for (var i = 0; i < data.Length; i++) { expectedHash.Append(data[i].ToString("x2")); } userAccount.EmailHash.ShouldEqual(expectedHash.ToString()); } }
public FubuContinuation Register(RegisterCommand command) { _service.CreateNew(command); return FubuContinuation.RedirectTo<HomeRequest>(); }