public void EditUserProfile() { var service = GetMockedUserService(); var user = new User(1, DateTime.MinValue); user.Roles = new List<string>(); var returnedProfile = new Profile(1); var profile = new Profile(); _mockProfileRepo.Setup(p => p.GetProfile(1)).Returns(returnedProfile); _mockProfileRepo.Setup(p => p.Update(It.IsAny<Profile>())).Callback<Profile>(p => profile = p); _mockTextParser.Setup(t => t.ForumCodeToHtml(It.IsAny<string>())).Returns("parsed"); var userEdit = new UserEditProfile { Aim = "a", Dob = new DateTime(2000,1,1), HideVanity = true, Icq = "i", IsDaylightSaving = true, IsPlainText = true, IsSubscribed = true, Location = "l", Facebook = "fb", Twitter = "tw", ShowDetails = true, Signature = "s", TimeZone = -7, Web = "w", YahooMessenger = "y" }; service.EditUserProfile(user, userEdit); _mockProfileRepo.Verify(p => p.Update(It.IsAny<Profile>()), Times.Once()); Assert.AreEqual("a", profile.Aim); Assert.AreEqual(new DateTime(2000, 1, 1), profile.Dob); Assert.IsTrue(profile.HideVanity); Assert.AreEqual("i", profile.Icq); Assert.IsTrue(profile.IsDaylightSaving); Assert.IsTrue(profile.IsPlainText); Assert.IsTrue(profile.IsSubscribed); Assert.AreEqual("l", profile.Location); Assert.AreEqual("fb", profile.Facebook); Assert.AreEqual("tw", profile.Twitter); Assert.IsTrue(profile.ShowDetails); Assert.AreEqual("parsed", profile.Signature); Assert.AreEqual(-7, profile.TimeZone); Assert.AreEqual("w", profile.Web); Assert.AreEqual("y", profile.YahooMessenger); }
public void EditProfile() { var controller = GetController(); var contextHelper = new HttpContextHelper(); controller.ControllerContext = new ControllerContext(contextHelper.MockContext.Object, new RouteData(), controller); var user = UserTest.GetTestUser(); controller.SetUser(user); var userEdit = new UserEditProfile(); var result = controller.EditProfile(userEdit); _userService.Verify(u => u.EditUserProfile(user, userEdit), Times.Once()); Assert.IsNotNullOrEmpty(result.ViewData["Result"].ToString()); }
public ViewResult EditProfile(UserEditProfile userEdit) { var user = this.CurrentUser(); if (user == null) return View("EditAccountNoUser"); _userService.EditUserProfile(user, userEdit); ViewBag.Result = Resources.ProfileUpdated; return View(userEdit); }
// TODO: this and some other stuff probably belongs in ProfileService public void EditUserProfile(User user, UserEditProfile userEditProfile) { var profile = _profileRepository.GetProfile(user.UserID); if (profile == null) throw new Exception(String.Format("No profile found for UserID {0}", user.UserID)); profile.IsSubscribed = userEditProfile.IsSubscribed; profile.ShowDetails = userEditProfile.ShowDetails; profile.IsPlainText = userEditProfile.IsPlainText; profile.HideVanity = userEditProfile.HideVanity; profile.TimeZone = userEditProfile.TimeZone; profile.IsDaylightSaving = userEditProfile.IsDaylightSaving; profile.Signature = _textParsingService.ForumCodeToHtml(userEditProfile.Signature); profile.Location = userEditProfile.Location; profile.Dob = userEditProfile.Dob; profile.Web = userEditProfile.Web; profile.Aim = userEditProfile.Aim; profile.Icq = userEditProfile.Icq; profile.YahooMessenger = userEditProfile.YahooMessenger; profile.Facebook = userEditProfile.Facebook; profile.Twitter = userEditProfile.Twitter; _profileRepository.Update(profile); }
public ViewResult EditProfile() { var user = this.CurrentUser(); if (user == null) return View("EditAccountNoUser"); var profile = _profileService.GetProfileForEdit(user); var userEdit = new UserEditProfile(profile); return View(userEdit); }