public void CreateDvsUserFromModel_should_throw_ArgumentNullException_if_dvsUserModel_password_is_empty()
		{
			var dvsUserModel = new CreateUserGeneralInfoViewModel
			{
				Password = string.Empty,
				Email = "*****@*****.**"
			};
			_target.Invoking(x => x.CreateDvsUserFromModel(dvsUserModel)).ShouldThrow<ArgumentNullException>();
		}
Example #2
0
		public ActionResult SaveDVSUser(CreateUserGeneralInfoViewModel model)
		{
			if (!ModelState.IsValid)
			{
				return View();
			}
			_dvsUserManagementService.CreateDvsUserFromModel(model);
			_taskManager.ScheduleManuallyRegisteredUserNotification(model.Email, model.Password);
			CommitProviderInstance.Commit();
			return RedirectToAction(NameHelper.DvsPipeline.Index);
		}
		public void CreateDvsUserFromModel_should_create_user()
		{
			var dvsUserModel = new CreateUserGeneralInfoViewModel
			{
				Password = "******",
				Email = "*****@*****.**",
				FirstName = "John",
				LastName = "Smith"
			};
			_referenceManager.GetRoleWithoutCache(Arg.Any<RoleType>()).Returns(new Role());
			_target.CreateDvsUserFromModel(dvsUserModel);
		}
Example #4
0
		public void CreateDvsUserFromModel(CreateUserGeneralInfoViewModel dvsUserModel)
		{
			if (dvsUserModel == null)
				throw new ArgumentNullException("UserViewModel cannot be null");
			if (string.IsNullOrWhiteSpace(dvsUserModel.Email))
				throw new ArgumentNullException("User Email cannot be null or blank");
			if (string.IsNullOrWhiteSpace(dvsUserModel.Password))
				throw new ArgumentNullException("User password cannot be null or blank");

			DvsUser dvsUser = new DvsUser();
			dvsUser.User = new User();
			dvsUser.ContactInfo = new DvsUserContact();
			dvsUser.User.DateCreated = DateTime.Now;
			dvsUser.User.Email = dvsUserModel.Email;
			dvsUser.User.FirstName = dvsUserModel.FirstName;
			dvsUser.User.LastName = dvsUserModel.LastName;
			dvsUser.User.Roles = new Role[] { _referenceManager.GetRoleWithoutCache(dvsUserModel.RoleType) };
			dvsUser.Status = DvsUserStatus.Active;

			CheckAndCreateDvsUser(dvsUser, dvsUserModel.Password);
		}
		public AppraiserUserCreateViewModel()
		{
			GeneralInfo = new CreateUserGeneralInfoViewModel();
			Contact = new AppraiserUserContactViewModel();
			CompanyInfo = new AppraiserUserCompanyInfoViewModel();
		}
Example #6
0
		public void CreateAppraiserUser_should_throw_exception_if_user_assigned_to_nonexsistent_branch()
		{
			var company = new AppraisalCompanyDetail() { Branches = new List<AppraisalCompanyBranch>() };
			ReferenceManager.GetRole(Arg.Any<RoleType>()).Returns(new Role() { Id = (int)RoleType.Appraiser });
			AppraisalCompanyManager.GetAppraisalCompanyById(1).Returns(company);
			var generalInfo = new CreateUserGeneralInfoViewModel()
			{
				Email = "email",
				Password = "******"
			};
			AppraiserUser appUser = new AppraiserUser();
			appUser.User = new User();
			appUser.User.Roles = new List<Role>() { new Role() { Id = (int)RoleType.Appraiser } };
			AppraiserManager.CheckAndCreateAppraiserUser(Arg.Any<User>(), generalInfo.Password, Arg.Any<AppraiserUserStatus>()).Returns(appUser);
			var contactInfo = new AppraiserUserContactViewModel() { PhysicalAddress = new AddressViewModel() };
			var companyInfo = new AppraiserUserCompanyInfoViewModel()
			{
				CompanyID = 1,
				BranchID = 10
			};
			var appraiser = new AppraiserUserCreateViewModel()
			{
				GeneralInfo = generalInfo,
				Contact = contactInfo,
				CompanyInfo = companyInfo
			};
			//act
			Target.Invoking(a => a.CreateAppraiserUser(appraiser)).ShouldThrow<ArgumentException>();
		}
Example #7
0
		public void CreateAppraiserUser_should_create_user()
		{
			var company = new AppraisalCompanyDetail() { Branches = new List<AppraisalCompanyBranch>() };
			AppraisalCompanyManager.GetAppraisalCompanyById(1).Returns(company);
			var generalInfo = new CreateUserGeneralInfoViewModel()
			{
				Email = "email",
				Password = "******",
				RoleType = RoleType.Appraiser
			};
			IAppraiserUserRepository appUserRepository = Substitute.For<IAppraiserUserRepository>();
			var _taskManager = Substitute.For<ITaskManager>();
			ReferenceManager.GetRoleWithoutCache(RoleType.Appraiser).Returns(new Role() { Id = (int)RoleType.Appraiser });
			AppraiserManager = new AppraiserManagement(Substitute.For<IUserRepository>(), appUserRepository, ReferenceManager, _taskManager, Substitute.For<IAscGovLicenseService>());
			Target = new AppraiserUserService(UsersManager, AppraiserManager,
				ReferenceManager, AppraisalCompanyManager,
				StatusHistoryManager, FeeManager, LicenseManager, AppraiserAccessManager,
				CryptographicProvider, DocumentService, Substitute.For<IGeocodingDataService>());
			var contactInfo = new AppraiserUserContactViewModel() { PhysicalAddress = new AddressViewModel() };
			var companyInfo = new AppraiserUserCompanyInfoViewModel()
			{
				CompanyID = 1
			};
			var appraiser = new AppraiserUserCreateViewModel()
			{
				GeneralInfo = generalInfo,
				Contact = contactInfo,
				CompanyInfo = companyInfo
			};

			var serviceAreaRadiuses = new Dictionary<RefServiceAreaRadiuse, string>();
			serviceAreaRadiuses.Add(new RefServiceAreaRadiuse() { ServiceAreaRadius = 1 }, "123");
			ReferenceManager.GetServiceAreaRadiuses().Returns(serviceAreaRadiuses);

			//act
			Target.CreateAppraiserUser(appraiser);
			appUserRepository.Received().Add(Arg.Any<AppraiserUser>());
		}