public void UserIsMappedFromModelUsingConstructorButWithoutUpdatingPasswordWhenPasswordIsNotSet()
        {
            var model = new UserEditModel { Name = "Jon", Email = "*****@*****.**" };
            var user = Mapper.Map<UserEditModel, 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.Null);
            Assert.That(user.PasswordSalt, Is.Null);
        }
Beispiel #2
0
        public ActionResult Edit(UserEditModel model)
        {
            if (ModelState.IsValid)
            {
                var user = Mapper.Map<UserEditModel, User>(model);
                session.Save<User>(user);
                return RedirectToAction("Index");
            }

            return View(model);
        }
        public void UserIsMappecFromModelUsingConstructorWhenPasswordIsSet()
        {
            var model = new UserEditModel {Name = "Jon", Email = "*****@*****.**", Password = "******"};
            var user = Mapper.Map<UserEditModel, 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"));
        }