SaveSiteSettings() public method

Saves all settings that are stored in the database, to the configuration table.
An datastore error occurred while saving the configuration.
public SaveSiteSettings ( SettingsViewModel model ) : void
model Roadkill.Core.Mvc.ViewModels.SettingsViewModel Summary data containing the settings.
return void
        public void SaveSiteSettings_Should_Persist_All_Values()
        {
            // Arrange
            ApplicationSettings appSettings = new ApplicationSettings();
            SiteSettings siteSettings = new SiteSettings()
            {
                AllowedFileTypes = "jpg, png, gif",
                AllowUserSignup = true,
                IsRecaptchaEnabled = true,
                MarkupType = "markuptype",
                RecaptchaPrivateKey = "privatekey",
                RecaptchaPublicKey = "publickey",
                SiteName = "sitename",
                SiteUrl = "siteurl",
                Theme = "theme",
            };
            SettingsViewModel validConfigSettings = new SettingsViewModel()
            {
                AllowedFileTypes = "jpg, png, gif",
                AllowUserSignup = true,
                IsRecaptchaEnabled = true,
                MarkupType = "markuptype",
                RecaptchaPrivateKey = "privatekey",
                RecaptchaPublicKey = "publickey",
                SiteName = "sitename",
                SiteUrl = "siteurl",
                Theme = "theme",
            };

            RepositoryMock repository = new RepositoryMock();

            DependencyManager iocSetup = new DependencyManager(appSettings, repository, new UserContext(null)); // context isn't used
            iocSetup.Configure();
            SettingsService settingsService = new SettingsService(appSettings, repository);

            // Act
            settingsService.SaveSiteSettings(validConfigSettings);

            // Assert
            SiteSettings actualSettings = settingsService.GetSiteSettings();

            Assert.That(actualSettings.AllowedFileTypes.Contains("jpg"), "AllowedFileTypes jpg");
            Assert.That(actualSettings.AllowedFileTypes.Contains("gif"), "AllowedFileTypes gif");
            Assert.That(actualSettings.AllowedFileTypes.Contains("png"), "AllowedFileTypes png");
            Assert.That(actualSettings.AllowUserSignup, Is.True, "AllowUserSignup");
            Assert.That(actualSettings.IsRecaptchaEnabled, Is.True, "IsRecaptchaEnabled");
            Assert.That(actualSettings.MarkupType, Is.EqualTo("markuptype"), "MarkupType");
            Assert.That(actualSettings.RecaptchaPrivateKey, Is.EqualTo("privatekey"), "RecaptchaPrivateKey");
            Assert.That(actualSettings.RecaptchaPublicKey, Is.EqualTo("publickey"), "RecaptchaPublicKey");
            Assert.That(actualSettings.SiteName, Is.EqualTo("sitename"), "SiteName");
            Assert.That(actualSettings.SiteUrl, Is.EqualTo("siteurl"), "SiteUrl");
            Assert.That(actualSettings.Theme, Is.EqualTo("theme"), "Theme");
        }
Esempio n. 2
0
		public void savesitesettings_should_persist_all_values()
		{
			// Arrange
			ApplicationSettings appSettings = new ApplicationSettings();
			SiteSettings siteSettings = new SiteSettings()
			{
				AllowedFileTypes = "jpg, png, gif",
				AllowUserSignup = true,
				IsRecaptchaEnabled = true,
				MarkupType = "markuptype",
				RecaptchaPrivateKey = "privatekey",
				RecaptchaPublicKey = "publickey",
				SiteName = "sitename",
				SiteUrl = "siteurl",
				Theme = "theme",
			};
			SettingsViewModel validConfigSettings = new SettingsViewModel()
			{
				AllowedFileTypes = "jpg, png, gif",
				AllowUserSignup = true,
				IsRecaptchaEnabled = true,
				MarkupType = "markuptype",
				RecaptchaPrivateKey = "privatekey",
				RecaptchaPublicKey = "publickey",
				SiteName = "sitename",
				SiteUrl = "siteurl",
				Theme = "theme",
			};

			SettingsService settingsService = new SettingsService(_repositoryFactory, appSettings);

			// Act
			settingsService.SaveSiteSettings(validConfigSettings);

			// Assert
			SiteSettings actualSettings = settingsService.GetSiteSettings();

			Assert.That(actualSettings.AllowedFileTypes.Contains("jpg"), "AllowedFileTypes jpg");
			Assert.That(actualSettings.AllowedFileTypes.Contains("gif"), "AllowedFileTypes gif");
			Assert.That(actualSettings.AllowedFileTypes.Contains("png"), "AllowedFileTypes png");
			Assert.That(actualSettings.AllowUserSignup, Is.True, "AllowUserSignup");
			Assert.That(actualSettings.IsRecaptchaEnabled, Is.True, "IsRecaptchaEnabled");
			Assert.That(actualSettings.MarkupType, Is.EqualTo("markuptype"), "MarkupType");
			Assert.That(actualSettings.RecaptchaPrivateKey, Is.EqualTo("privatekey"), "RecaptchaPrivateKey");
			Assert.That(actualSettings.RecaptchaPublicKey, Is.EqualTo("publickey"), "RecaptchaPublicKey");
			Assert.That(actualSettings.SiteName, Is.EqualTo("sitename"), "SiteName");
			Assert.That(actualSettings.SiteUrl, Is.EqualTo("siteurl"), "SiteUrl");
			Assert.That(actualSettings.Theme, Is.EqualTo("theme"), "Theme");
		}