FillFromApplicationSettings() public method

public FillFromApplicationSettings ( Roadkill.Core.Configuration.ApplicationSettings applicationSettings ) : void
applicationSettings Roadkill.Core.Configuration.ApplicationSettings
return void
示例#1
0
		public ActionResult Index(SettingsViewModel model)
		{
			if (ModelState.IsValid)
			{
				_configReaderWriter.Save(model);
			
				_settingsService.SaveSiteSettings(model);
				_siteCache.RemoveMenuCacheItems();

				// Refresh the AttachmentsDirectoryPath using the absolute attachments path, as it's calculated in the constructor
				ApplicationSettings appSettings = _configReaderWriter.GetApplicationSettings();
				model.FillFromApplicationSettings(appSettings);
				model.UpdateSuccessful = true;
			}

			return View(model);
		}
		public void fillfromapplicationsettings_should_convert_applicationsettings_to_properties()
		{
			// Arrange
			ApplicationSettings appSettings = new ApplicationSettings()
			{
				AdminRoleName = "admin role name",
				AttachmentsFolder = @"c:\AttachmentsFolder",
				UseObjectCache = true,
				UseBrowserCache = true,
				ConnectionString = "connection string",
				DatabaseName = "SqlServer2008",
				EditorRoleName = "editor role name",
				LdapConnectionString = "ldap connection string",
				LdapUsername = "******",
				LdapPassword = "******",
				UseWindowsAuthentication = true,
				IsPublicSite = false,
				IgnoreSearchIndexErrors = false
			};

			// Act
			SettingsViewModel model = new SettingsViewModel();
			model.FillFromApplicationSettings(appSettings);

			// Assert
			Assert.That(model.AdminRoleName, Is.EqualTo(appSettings.AdminRoleName));
			Assert.That(model.AttachmentsFolder, Is.EqualTo(appSettings.AttachmentsFolder));
			Assert.That(model.UseObjectCache, Is.EqualTo(appSettings.UseObjectCache));
			Assert.That(model.UseBrowserCache, Is.EqualTo(appSettings.UseBrowserCache));
			Assert.That(model.ConnectionString, Is.EqualTo(appSettings.ConnectionString));
			Assert.That(model.DatabaseName, Is.EqualTo(appSettings.DatabaseName));
			Assert.That(model.EditorRoleName, Is.EqualTo(appSettings.EditorRoleName));
			Assert.That(model.LdapConnectionString, Is.EqualTo(appSettings.LdapConnectionString));
			Assert.That(model.LdapUsername, Is.EqualTo(appSettings.LdapUsername));
			Assert.That(model.LdapPassword, Is.EqualTo(appSettings.LdapPassword));
			Assert.That(model.UseWindowsAuth, Is.EqualTo(appSettings.UseWindowsAuthentication));
			Assert.That(model.IsPublicSite, Is.EqualTo(appSettings.IsPublicSite));
			Assert.That(model.IgnoreSearchIndexErrors, Is.EqualTo(appSettings.IgnoreSearchIndexErrors));
		}