Esempio n. 1
0
		public void SaveAppraiserProfile_should_throw_exception_if_login_or_profile_are_null()
		{
			var appraiserViewModel = new AppraiserUserProfileViewModel() { Email = "*****@*****.**", FirstName = "anotherFirstName", LastName = "anotherLastName" };
			//act
			Target.Invoking(y => y.SaveAppraiserProfile(null, "login")).ShouldThrow<ArgumentNullException>().And.ParamName.Should().Contain("profile");
			Target.Invoking(y => y.SaveAppraiserProfile(appraiserViewModel, "           ")).ShouldThrow<ArgumentNullException>().And.ParamName.Should().Contain("email");
		}
Esempio n. 2
0
		private ActionResult GetProfileView(AppraiserUserProfileViewModel appraiserProfileViewModel, int? userId)
		{
			ViewBag.Header = appraiserProfileViewModel.SectionTitle;
			ViewBag.IsOwnPage = appraiserProfileViewModel.IsOwnPage;
			ViewBag.CurrentStep = NameHelper.AppraiserProfile.Profile;
			return View(NameHelper.AppraiserProfile.Profile, GetViewModel(appraiserProfileViewModel, userId));
		}
		public void profile_appraiser_should_not_change_role_and_status()
		{
			//arrange
			string currentUserEmail = "*****@*****.**";
			string firstName = "John";
			string lastName = "Doe";
			string nextStep = "Contact";
			int editUserId = 6;
			AppraiserUserStatus status = AppraiserUserStatus.Suspended;
			RoleType role = RoleType.DvsSuperAdmin;
			var formValues = new FormCollection() {
        {"EditUserId", editUserId.ToString()},
        {"FirstName", firstName},
        {"LastName", lastName},
        {"nextStep", nextStep},
        {"CurrentRoleId", ((int)role).ToString()},
        {"Status", status.ToString()},
				{"TIN", "test"},
				{"TINType", null}
      };
			AppraiserAccessManager.IsOtherUserDataAvailable(Arg.Any<int?>()).Returns(true);
			AppraiserAccessManager.AppraisalEditResult securityResult = new AppraiserAccessManager.AppraisalEditResult()
			{
				AllowEditRole = false,
				AllowEditStatus = false,
				IsCurrentUser = false,
				Message = "Some msg"
			};
			InitTestUser(RoleType.Appraiser, currentUserEmail);
			Target.ValueProvider = formValues.ToValueProvider();
			AppraiserAccessManager.CheckAccessToUserData(editUserId).Returns(true);
			AppraiserAccessManager.AllowEditRole(editUserId).Returns(securityResult);
			AppraiserAccessManager.AllowEditStatus(editUserId).Returns(securityResult);

			AppraiserUserProfileViewModel profileModel = new AppraiserUserProfileViewModel()
			{
				Email = "*****@*****.**",
				EditUserId = editUserId,
				CurrentRoleId = 1,
				FirstName = "FirstTest",
				LastName = "LastTest",
				Status = AppraiserUserStatus.Active
			};
			AppraiserUserService.GetAppraiserProfile(currentUserEmail, editUserId).Returns(profileModel);

			AppraiserUserProfileViewModel expectedModel = new AppraiserUserProfileViewModel()
			{
				Email = profileModel.Email,
				EditUserId = editUserId,
				FirstName = firstName,
				LastName = lastName,
				Status = profileModel.Status,
				CurrentRoleId = profileModel.CurrentRoleId
			};

			//act
			Target.Profile(nextStep, editUserId);

			AppraiserUserService.Received().SaveAppraiserProfile(Arg.Is<AppraiserUserProfileViewModel>(x => x.Email == expectedModel.Email &&
				x.EditUserId == expectedModel.EditUserId &&
				x.FirstName == expectedModel.FirstName &&
				x.LastName == expectedModel.LastName &&
				x.Status == expectedModel.Status &&
				x.CurrentRoleId == expectedModel.CurrentRoleId), currentUserEmail);
		}