Exemplo n.º 1
0
        public void UserIsMappedFromInitialUserModelUsingConstructorWhenPasswordIsSet()
        {
            var model = new InitialSetupModel { Name = "Jon", Email = "*****@*****.**", Password = "******" };
            var user = Mapper.Map<InitialSetupModel, User>(model);

            Assert.That(user.Name, Is.EqualTo(model.Name));
            Assert.That(user.Email, Is.EqualTo(model.Email));
            Assert.That(user.Active, Is.True);
            Assert.That(user.PasswordHashed, Is.Not.Null.And.Not.Empty);
            Assert.That(user.PasswordHashed, Is.EqualTo("hashedpassword"));
            Assert.That(user.PasswordSalt, Is.Not.Null.And.Not.Empty);
            Assert.That(user.PasswordSalt, Is.EqualTo("salt"));
        }
Exemplo n.º 2
0
        public ActionResult Index(InitialSetupModel user)
        {
            if (ModelState.IsValid)
            {
                var entity = Mapper.Map<InitialSetupModel, User>(user);
                session.Store(entity);
                session.SaveChanges();

                return RedirectToAction("index", "authentication");
            }

            return View("Index", user);
        }
Exemplo n.º 3
0
        public void IndexShouldRedirectWhenUserIsSaved()
        {
            var crypto = M<ICryptographer>();
            var locator = M<IServiceLocator>();
            ServiceLocator.SetLocatorProvider(() => locator);
            locator.Expect(l => l.GetInstance<ICryptographer>()).Return(crypto);

            var session = Store.OpenSession();
            locator.Expect(l => l.GetInstance<IDocumentSession>()).Return(session);

            var controller = new SetupController();
            var model = new InitialSetupModel { Email = "*****@*****.**", Password = "******", PasswordConfirm = "test" };

            var result = controller.Index(model);

            result.AssertActionRedirect().ToController("authentication").ToAction("index");

            session.Delete(session.Query<User>().First());
            session.SaveChanges();
        }