public JsonResult PopulateDetails(UserModel model)
        {
            UserResultModel userResultModel = new UserResultModel();
            if (String.IsNullOrEmpty(model.UserId))
            {
                userResultModel.Message = "UserId can not be blank";
                return Json(userResultModel);
            }

            User user = _userRepository.GetUser(model.UserId);

            if (user == null)
            {
                userResultModel.Message = String.Format("No UserId found for {0}", model.UserId);
                return Json(userResultModel);
            }
            userResultModel.LastName = user.LastName;
            userResultModel.FirstName = user.FirstName;
            userResultModel.Message = String.Empty; //success message is empty in this case

            return Json(userResultModel);
        }
        public void Should_return_corresponding_User_Details()
        {
            const string userId = "userId";
            User user = new User
                            {
                                LastName = "TestLastName",
                                FirstName = "TestFirstName"
                            };

            _userRepository.Expect(x => x.GetUser(userId)).IgnoreArguments().Return(user);

            UserModel userModel = new UserModel {UserId = "userId"};

            JsonResult result = _userController.PopulateDetails(userModel);

            Assert.IsNotNull(result);

            Assert.IsAssignableFrom(typeof (UserResultModel), result.Data);
            UserResultModel userResultModel = (UserResultModel) result.Data;

            Assert.AreEqual(user.LastName, userResultModel.LastName);
            Assert.AreEqual(user.FirstName, userResultModel.FirstName);
            Assert.IsEmpty(userResultModel.Message);
        }
 public ActionResult UserDetails()
 {
     UserModel model = new UserModel();
     return View(model);
 }