Exemplo n.º 1
0
        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);
        }
Exemplo n.º 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);
        }
Exemplo n.º 3
0
        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"));
        }