public void Password_Display()
        {
            var model = new CreateUserViewModel();
             var displayAttribute = AttributeHelper.GetDisplayAttribute( () => model.NewPassword );

             Assert.IsNotNull( displayAttribute );
             Assert.AreEqual( "Password:", displayAttribute.Name );
        }
        public void ConfirmPassword_ComparedToPassword()
        {
            var model = new CreateUserViewModel();
             var compareAttribute = AttributeHelper.GetCompareAttribute( () => model.ConfirmPassword );

             Assert.IsNotNull( compareAttribute );
             Assert.AreEqual( "NewPassword", compareAttribute.OtherProperty );
        }
        public void Password_MinStringLength()
        {
            var model = new CreateUserViewModel();
             var stringLengthAttribute = AttributeHelper.GetStringLengthAttribute( () => model.NewPassword );

             Assert.IsNotNull( stringLengthAttribute );
             Assert.AreEqual( 6, stringLengthAttribute.MinimumLength );
             Assert.AreEqual( 100, stringLengthAttribute.MaximumLength );
        }
Example #4
0
        public ActionResult Create( string callingAction = null, string callingId = null )
        {
            var viewModel = new CreateUserViewModel()
             {
            Mode = EditMode.Create
             };

             ViewBag.EditorTitle = "New User";

             UpdateNavigationStack( viewModel, null, callingAction, callingId );

             return PartialView( "_ModalEditor", viewModel );
        }
Example #5
0
        public virtual ActionResult Create( CreateUserViewModel viewModel )
        {
            var session = _sessionFactory.GetCurrentSession();
             using (var transaction = session.BeginTransaction())
             {
            try
            {
               viewModel.Mode = EditMode.Create;
               if (ModelState.IsValid)
               {
                  var model = Mapper.Map<User>( viewModel );
                  model.SetPassword( viewModel.NewPassword );

                  if (model.IsValidFor( Data.TransactionType.Insert ))
                  {
                     session.Save( model );
                     transaction.Commit();
                     return RedirectToAction( "Index" );
                  }
                  else
                  {
                     foreach (var message in model.GetErrorMessages())
                     {
                        ModelState.AddModelError( message.Key, message.Value );
                     }
                  }
               }
               transaction.Commit();
            }
            catch (Exception e)
            {
               Log.Error( e, "Create POST Error" );
               transaction.Rollback();
            }

            return View( viewModel );
             }
        }
        public void Password_IsRequired()
        {
            var model = new CreateUserViewModel();

             Assert.IsNotNull( AttributeHelper.GetRequiredAttribute( () => model.NewPassword ) );
        }
        public void CreateUser_IsNewUser()
        {
            var model = new CreateUserViewModel();

             Assert.IsTrue( model.IsNewUser );
        }
        public void CreatePost_DoesNotCopyMessagesToModelStateIfValidationSucceeds()
        {
            var model = new CreateUserViewModel()
             {
            Id = Guid.NewGuid(),
            FirstName = "Bob",
            MiddleName = "The",
            LastName = "Builder",
            UserName = "******",
            NewPassword = "******",
            ConfirmPassword = "******"
             };

             var result = _controller.Create( model );

             Assert.AreEqual( 0, _controller.ModelState.Count );
        }