public void GetSiteSettings_Should_Return_Correct_Settings()
        {
            // Arrange
            SiteSettings expectedSettings = new SiteSettings();
            expectedSettings.Theme = "Mytheme";
            expectedSettings.SiteName = "Mysitename";
            expectedSettings.SiteUrl = "SiteUrl";
            expectedSettings.RecaptchaPrivateKey = "RecaptchaPrivateKey";
            expectedSettings.RecaptchaPublicKey = "RecaptchaPublicKey";
            expectedSettings.MarkupType = "MarkupType";
            expectedSettings.IsRecaptchaEnabled = true;
            expectedSettings.AllowedFileTypes = "AllowedFileTypes";
            expectedSettings.OverwriteExistingFiles = true;
            expectedSettings.HeadContent = "some head content";
            expectedSettings.MenuMarkup = "some menu markup";
            _repository.SiteSettings = expectedSettings;

            // Act
            SiteSettings actualSettings = _settingsService.GetSiteSettings();

            // Assert
            Assert.That(actualSettings.Theme, Is.EqualTo(expectedSettings.Theme));
            Assert.That(actualSettings.SiteName, Is.EqualTo(expectedSettings.SiteName));
            Assert.That(actualSettings.SiteUrl, Is.EqualTo(expectedSettings.SiteUrl));
            Assert.That(actualSettings.RecaptchaPrivateKey, Is.EqualTo(expectedSettings.RecaptchaPrivateKey));
            Assert.That(actualSettings.RecaptchaPublicKey, Is.EqualTo(expectedSettings.RecaptchaPublicKey));
            Assert.That(actualSettings.MarkupType, Is.EqualTo(expectedSettings.MarkupType));
            Assert.That(actualSettings.IsRecaptchaEnabled, Is.EqualTo(expectedSettings.IsRecaptchaEnabled));
            Assert.That(actualSettings.AllowedFileTypes, Is.EqualTo(expectedSettings.AllowedFileTypes));
            Assert.That(actualSettings.OverwriteExistingFiles, Is.EqualTo(expectedSettings.OverwriteExistingFiles));
            Assert.That(actualSettings.HeadContent, Is.EqualTo(expectedSettings.HeadContent));
            Assert.That(actualSettings.MenuMarkup, Is.EqualTo(expectedSettings.MenuMarkup));
        }
		public void savesitesettings_and_getsitesettings()
		{
			// Arrange 
			var repository = GetRepository(ConnectionString);
			SiteSettings expectedSettings = new SiteSettings()
			{
				AllowedFileTypes = "exe, virus, trojan",
				AllowUserSignup = true,
				IsRecaptchaEnabled = true,
				MarkupType = "Test",
				RecaptchaPrivateKey = "RecaptchaPrivateKey",
				RecaptchaPublicKey = "RecaptchaPublicKey",
				SiteName = "NewSiteName",
				SiteUrl = "http://sitename",
				Theme = "newtheme"
			};

			// Act
			repository.SaveSettings(expectedSettings);

			// Assert
			SiteSettings actualSettings = GetSiteSettings();

			Assert.That(actualSettings.AllowedFileTypes, Is.EqualTo(expectedSettings.AllowedFileTypes));
			Assert.That(actualSettings.AllowUserSignup, Is.EqualTo(expectedSettings.AllowUserSignup));
			Assert.That(actualSettings.IsRecaptchaEnabled, Is.EqualTo(expectedSettings.IsRecaptchaEnabled));
			Assert.That(actualSettings.MarkupType, Is.EqualTo(expectedSettings.MarkupType));
			Assert.That(actualSettings.RecaptchaPrivateKey, Is.EqualTo(expectedSettings.RecaptchaPrivateKey));
			Assert.That(actualSettings.RecaptchaPublicKey, Is.EqualTo(expectedSettings.RecaptchaPublicKey));
			Assert.That(actualSettings.SiteName, Is.EqualTo(expectedSettings.SiteName));
			Assert.That(actualSettings.SiteUrl, Is.EqualTo(expectedSettings.SiteUrl));
			Assert.That(actualSettings.Theme, Is.EqualTo(expectedSettings.Theme));
		}
		/// <summary>
		/// Saves all settings that are stored in the database, to the configuration table.
		/// </summary>
		/// <param name="model">Summary data containing the settings.</param>
		/// <exception cref="DatabaseException">An datastore error occurred while saving the configuration.</exception>
		public void SaveSiteSettings(SettingsViewModel model)
		{
			try
			{
				SiteSettings siteSettings = new SiteSettings();
				siteSettings.AllowedFileTypes = model.AllowedFileTypes;
				siteSettings.AllowUserSignup = model.AllowUserSignup;
				siteSettings.IsRecaptchaEnabled = model.IsRecaptchaEnabled;
				siteSettings.MarkupType = model.MarkupType;
				siteSettings.RecaptchaPrivateKey = model.RecaptchaPrivateKey;
				siteSettings.RecaptchaPublicKey = model.RecaptchaPublicKey;
				siteSettings.SiteUrl = model.SiteUrl;
				siteSettings.SiteName = model.SiteName;
				siteSettings.Theme = model.Theme;

				// v2.0
				siteSettings.OverwriteExistingFiles = model.OverwriteExistingFiles;
				siteSettings.HeadContent = model.HeadContent;
				siteSettings.MenuMarkup = model.MenuMarkup;

                // Pipeline
                siteSettings.EnableMailChimp = model.EnableMailChimp;
                siteSettings.MailChimpApiKey = model.MailChimpApiKey;
                siteSettings.MailChimpListId = model.MailChimpListId;

				Repository.SaveSiteSettings(siteSettings);
			}
			catch (DatabaseException ex)
			{
				throw new DatabaseException(ex, "An exception occurred while saving the site configuration.");
			}
		}
示例#4
0
		/// <summary>
		/// Saves all settings that are stored in the database, to the configuration table.
		/// </summary>
		/// <param name="model">Summary data containing the settings.</param>
		/// <exception cref="DatabaseException">An datastore error occurred while saving the configuration.</exception>
		public void SaveSiteSettings(SettingsViewModel model)
		{
			try
			{
				SiteSettings siteSettings = new SiteSettings();
				siteSettings.AllowedFileTypes = model.AllowedFileTypes;
				siteSettings.AllowUserSignup = model.AllowUserSignup;
				siteSettings.IsRecaptchaEnabled = model.IsRecaptchaEnabled;
				siteSettings.MarkupType = model.MarkupType;
				siteSettings.RecaptchaPrivateKey = model.RecaptchaPrivateKey;
				siteSettings.RecaptchaPublicKey = model.RecaptchaPublicKey;
				siteSettings.SiteUrl = model.SiteUrl;
				siteSettings.SiteName = model.SiteName;
				siteSettings.Theme = model.Theme;

				// v2.0
				siteSettings.OverwriteExistingFiles = model.OverwriteExistingFiles;
				siteSettings.HeadContent = model.HeadContent;
				siteSettings.MenuMarkup = model.MenuMarkup;

				var repository = _repositoryFactory.GetSettingsRepository(_applicationSettings.DatabaseName, _applicationSettings.ConnectionString);
				repository.SaveSiteSettings(siteSettings);
			}
			catch (DatabaseException ex)
			{
				throw new DatabaseException(ex, "An exception occurred while saving the site configuration.");
			}
		}
		public void SaveSiteSettings(SiteSettings settings)
		{
			if (ThrowSaveSiteSettingsException)
				throw new DatabaseException("Something happened", null);

			SiteSettings = settings;
		}
		public void SaveSettings(SiteSettings siteSettings)
		{
			SaveSettingsCalled = true;
			SiteSettings = siteSettings;

			if (ThrowInstallException)
				throw new DatabaseException("Something happened", null);
		}
示例#7
0
		public RepositoryMock()
		{
			Pages = new List<Page>();
			PageContents = new List<PageContent>();
			Users = new List<User>();
			SiteSettings = new SiteSettings();
			TextPlugins = new List<TextPlugin>();
		}
示例#8
0
        /// <summary>
        /// Initializes a new instance of the <see cref="EmailTemplate"/> class.
        /// </summary>
        /// <param name="applicationSettings"></param>
        /// <param name="siteSettings"></param>
        /// <param name="emailClient">The <see cref="IEmailClient"/> to send the mail through. If this 
        /// parameter is null, then <see cref="EmailClient"/> is used</param>
        protected EmailTemplate(ApplicationSettings applicationSettings, SiteSettings siteSettings, IEmailClient emailClient)
        {
            ApplicationSettings = applicationSettings;
            SiteSettings = siteSettings;

            EmailClient = emailClient;
            if (EmailClient == null)
                EmailClient = new EmailClient();
        }
		public void Setup()
		{
			_container = new MocksAndStubsContainer();

			_applicationSettings = _container.ApplicationSettings;
			_siteSettings = _container.SettingsService.GetSiteSettings();

			_pluginFactory = _container.PluginFactory;
			_pageRepository = _container.PageRepository;
		}
		public SiteSettings GetSiteSettings()
		{
			SiteSettings siteSettings = new SiteSettings();
			SiteConfigurationEntity entity = UnitOfWork.FindById<SiteConfigurationEntity>(SiteSettings.SiteSettingsId);

			if (entity != null)
			{
				siteSettings = SiteSettings.LoadFromJson(entity.Content);
			}
			else
			{
				Log.Warn("No site settings could be found in the database, using a default instance");
			}

			return siteSettings;
		}
示例#11
0
        public void ReplaceTokens_Should_Get_SiteSettings_From_Repository()
        {
            // Issue #229
            // Arrange
            EmailTemplateStub emailTemplate = new EmailTemplateStub(_applicationSettings, _repository, _emailClientMock);
            UserViewModel userModel = new UserViewModel();

            SiteSettings expectedSettings = new SiteSettings();
            expectedSettings.SiteName = "MySite";
            expectedSettings.SiteUrl = "http://www.roadkillwiki.iz.de.biz";
            _repository.SaveSiteSettings(expectedSettings);

            // Act
            emailTemplate.ReplaceTokens(userModel, "not used");
            SiteSettings actualSettings = emailTemplate.GetSiteSettings();

            // Assert
            Assert.That(actualSettings, Is.EqualTo(expectedSettings));
        }
		public void SaveSiteSettings(SiteSettings siteSettings)
		{
			SiteConfigurationEntity entity = UnitOfWork.FindById<SiteConfigurationEntity>(SiteSettings.SiteSettingsId);

			if (entity == null || entity.Id == Guid.Empty)
			{
				entity = new SiteConfigurationEntity();
				entity.Id = SiteSettings.SiteSettingsId;
				entity.Version = ApplicationSettings.ProductVersion.ToString();
				entity.Content = siteSettings.GetJson();
				UnitOfWork.Add(entity);
			}
			else
			{
				entity.Version = ApplicationSettings.ProductVersion.ToString();
				entity.Content = siteSettings.GetJson();
			}

			UnitOfWork.SaveChanges();
		}
		public void SaveSettings(SiteSettings siteSettings)
		{
			try
			{
				using (IUnitOfWork unitOfWork = _context.CreateUnitOfWork())
				{
					var entity = new Roadkill.Core.Database.LightSpeed.SiteConfigurationEntity();
					entity.Id = SiteSettings.SiteSettingsId;
					entity.Version = ApplicationSettings.ProductVersion;
					entity.Content = siteSettings.GetJson();

					unitOfWork.Add(entity);
					unitOfWork.SaveChanges();
				}
			}
			catch (Exception e)
			{
				throw new DatabaseException(e, "Install failed: unable to connect to the database using '{0}' - {1}", ConnectionString, e.Message);
			}
		}
示例#14
0
        /// <summary>
        /// Fills this instance of SettingsViewModel using the properties from the ApplicationSettings 
        /// and the SiteSettings.
        /// </summary>
        public SettingsViewModel(ApplicationSettings applicationSettings, SiteSettings siteSettings)
            : this()
        {
            // ApplicationSettings
            FillFromApplicationSettings(applicationSettings);

            // SiteSettings
            AllowedFileTypes = string.Join(",", siteSettings.AllowedFileTypesList);
            AllowUserSignup = siteSettings.AllowUserSignup;
            IsRecaptchaEnabled = siteSettings.IsRecaptchaEnabled;
            MarkupType = siteSettings.MarkupType;
            RecaptchaPrivateKey = siteSettings.RecaptchaPrivateKey;
            RecaptchaPublicKey = siteSettings.RecaptchaPublicKey;
            SiteName = siteSettings.SiteName;
            SiteUrl = siteSettings.SiteUrl;
            Theme = siteSettings.Theme;
            OverwriteExistingFiles = siteSettings.OverwriteExistingFiles;
            HeadContent = siteSettings.HeadContent;
            MenuMarkup = siteSettings.MenuMarkup;
        }
		public void Setup()
		{
			// WikiController setup (use WikiController as it's the one typically used by views)
			_container = new MocksAndStubsContainer();

			_applicationSettings = _container.ApplicationSettings;
			_context = _container.UserContext;
			_pageRepository = _container.PageRepository;
			_pluginFactory = _container.PluginFactory;
			_settingsService = _container.SettingsService;
			_siteSettings = _settingsService.GetSiteSettings();
			_siteSettings.Theme = "Mediawiki";

			_userService = _container.UserService;
			_historyService = _container.HistoryService;
			_pageService = _container.PageService;

			_wikiController = new WikiController(_applicationSettings, _userService, _pageService, _context, _settingsService);
			_wikiController.SetFakeControllerContext("~/wiki/index/1");
			_urlHelper = _wikiController.Url;
		}
示例#16
0
		public void Install(SettingsViewModel model)
		{
			try
			{
				IInstallerRepository installerRepository = _getRepositoryFunc(model.DatabaseName, model.ConnectionString);
				installerRepository.CreateSchema();

				if (model.UseWindowsAuth == false)
				{
					installerRepository.AddAdminUser(model.AdminEmail, "admin", model.AdminPassword);
				}

				SiteSettings siteSettings = new SiteSettings();
				siteSettings.AllowedFileTypes = model.AllowedFileTypes;
				siteSettings.AllowUserSignup = model.AllowUserSignup;
				siteSettings.IsRecaptchaEnabled = model.IsRecaptchaEnabled;
				siteSettings.MarkupType = model.MarkupType;
				siteSettings.RecaptchaPrivateKey = model.RecaptchaPrivateKey;
				siteSettings.RecaptchaPublicKey = model.RecaptchaPublicKey;
				siteSettings.SiteUrl = model.SiteUrl;
				siteSettings.SiteName = model.SiteName;
				siteSettings.Theme = model.Theme;

				// v2.0
				siteSettings.OverwriteExistingFiles = model.OverwriteExistingFiles;
				siteSettings.HeadContent = model.HeadContent;
				siteSettings.MenuMarkup = model.MenuMarkup;
				installerRepository.SaveSettings(siteSettings);

				// Attachments handler needs re-registering
				var appSettings = Locator.GetInstance<ApplicationSettings>();
				var fileService = Locator.GetInstance<IFileService>();
				AttachmentRouteHandler.RegisterRoute(appSettings, RouteTable.Routes, fileService);
			}
			catch (DatabaseException ex)
			{
				throw new DatabaseException(ex, "An exception occurred while saving the site configuration.");
			}
		}
示例#17
0
		public CreoleParser(ApplicationSettings applicationSettings, SiteSettings siteSettings)
		{
			_applicationSettings = applicationSettings;
			AddIdToParagraphTags = false;
			HTMLAttributes = new Dictionary<string, string>();
			InterWiki = new Dictionary<string, string>();
			TabStop = 7; // default to 7 char tabstop
			NoWikiEscapeStart = "{{{";
			NoWikiEscapeEnd = "}}}";

			if (siteSettings != null)
				InterWiki.Add("tag", siteSettings.SiteUrl + "/pages/tag/");
		}
示例#18
0
		public void getjson_should_return_known_json()
		{
			// Arrange
			string expectedJson = @"{
  ""AllowedFileTypes"": ""pdf, swf, avi"",
  ""AllowUserSignup"": true,
  ""IsRecaptchaEnabled"": true,
  ""MarkupType"": ""Markdown"",
  ""RecaptchaPrivateKey"": ""captchaprivatekey"",
  ""RecaptchaPublicKey"": ""captchapublickey"",
  ""SiteUrl"": ""http://siteurl"",
  ""SiteName"": ""my sitename"",
  ""Theme"": ""Mytheme"",
  ""OverwriteExistingFiles"": false,
  ""HeadContent"": """",
  ""MenuMarkup"": ""* %mainpage%\r\n* %categories%\r\n* %allpages%\r\n* %newpage%\r\n* %managefiles%\r\n* %sitesettings%\r\n\r\n"",
  ""PluginLastSaveDate"": ""{today}""
}";

			expectedJson = expectedJson.Replace("{today}", DateTime.Today.ToUniversalTime().ToString("s") + "Z"); // Z = zero offset from UTC

			SiteSettings settings = new SiteSettings();
			settings.AllowedFileTypes = "pdf, swf, avi";
			settings.AllowUserSignup = true;
			settings.IsRecaptchaEnabled = true;
			settings.MarkupType = "Markdown";
			settings.RecaptchaPrivateKey = "captchaprivatekey";
			settings.RecaptchaPublicKey = "captchapublickey";
			settings.SiteUrl = "http://siteurl";
			settings.SiteName = "my sitename";
			settings.Theme = "Mytheme";
			settings.PluginLastSaveDate = DateTime.Today.ToUniversalTime(); // ideally property this would take an IDate...something to refactor in for the future if there are problems.

			// Act
			string actualJson = settings.GetJson();

			// Assert
			Assert.That(actualJson, Is.EqualTo(expectedJson), actualJson);
		}
示例#19
0
 /// <summary>
 /// Gets a complete URL path to an item in the current theme directory.
 /// </summary>
 /// <param name="helper">The helper.</param>
 /// <param name="relativePath">The filename or path inside the current theme directory.</param>
 /// <returns>A url path to the item, e.g. '/MySite/Themes/Mediawiki/logo.png'</returns>
 public static string ThemeContent(this UrlHelper helper, string relativePath, SiteSettings settings)
 {
     return helper.Content(settings.ThemePath + "/" + relativePath);
 }
示例#20
0
        /// <summary>
        /// Replaces all tokens in the html and plain text views.
        /// </summary>
        /// <param name="model"></param>
        /// <param name="template"></param>
        protected internal virtual string ReplaceTokens(UserViewModel model, string template)
        {
            if (SiteSettings == null)
                SiteSettings = Repository.GetSiteSettings();

            string result = template;

            result = result.Replace("{FIRSTNAME}", model.Firstname);
            result = result.Replace("{LASTNAME}", model.Lastname);
            result = result.Replace("{EMAIL}", model.NewEmail);
            result = result.Replace("{USERNAME}", model.NewUsername);
            result = result.Replace("{SITEURL}", SiteSettings.SiteUrl);
            result = result.Replace("{ACTIVATIONKEY}", model.ActivationKey);
            result = result.Replace("{RESETKEY}", model.PasswordResetKey);
            result = result.Replace("{USERID}", model.Id.ToString());
            result = result.Replace("{SITENAME}", SiteSettings.SiteName);

            if (HttpContext.Current != null)
                result = result.Replace("{REQUEST_IP}", HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"]);

            return result;
        }
示例#21
0
 public ResetPasswordEmail(ApplicationSettings applicationSettings, SiteSettings siteSettings, IEmailClient emailClient)
     : base(applicationSettings, siteSettings, emailClient)
 {
 }
示例#22
0
		public void replacetokens_should_replace_all_tokens_from_model()
		{
			// Arrange
			EmailTemplateStub emailTemplate = new EmailTemplateStub(_applicationSettings, _settingsRepository, _emailClientMock);
			UserViewModel userModel = new UserViewModel();
			userModel.ActivationKey = "key";
			userModel.ExistingUsername = "******";
			userModel.Firstname = "firstname";
			userModel.Id = Guid.NewGuid();
			userModel.Lastname = "lastname";
			userModel.NewEmail = "NewEmail";
			userModel.PasswordResetKey = "resetkey";

			SiteSettings siteSettings = new SiteSettings();
			siteSettings.SiteName = "MySite";
			siteSettings.SiteUrl = "http://www.roadkillwiki.iz.de.biz";
			_settingsRepository.SaveSiteSettings(siteSettings);

			StringBuilder templateBuilder = new StringBuilder();
			templateBuilder.AppendLine("{FIRSTNAME}");
			templateBuilder.AppendLine("{LASTNAME}");
			templateBuilder.AppendLine("{EMAIL}");
			templateBuilder.AppendLine("{USERNAME}");
			templateBuilder.AppendLine("{ACTIVATIONKEY}");
			templateBuilder.AppendLine("{RESETKEY}");
			templateBuilder.AppendLine("{USERID}");
			templateBuilder.AppendLine("{SITENAME}");
			templateBuilder.AppendLine("{SITEURL}");

			StringBuilder expectedContent = new StringBuilder();
			expectedContent.AppendLine(userModel.Firstname);
			expectedContent.AppendLine(userModel.Lastname);
			expectedContent.AppendLine(userModel.NewEmail);
			expectedContent.AppendLine(userModel.NewUsername);
			expectedContent.AppendLine(userModel.ActivationKey);
			expectedContent.AppendLine(userModel.PasswordResetKey);
			expectedContent.AppendLine(userModel.Id.ToString());
			expectedContent.AppendLine(siteSettings.SiteName);
			expectedContent.AppendLine(siteSettings.SiteUrl);

			// Act
			string actualTemplate = emailTemplate.ReplaceTokens(userModel, templateBuilder.ToString());

			// Assert
			Assert.That(actualTemplate, Is.EqualTo(expectedContent.ToString()));
		}
示例#23
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");
		}
        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");
        }
        public void Constructor_Should_Remove_Spaces_From_SiteSettings_Allow_File_Types()
        {
            // Arrange
            ApplicationSettings appSettings = new ApplicationSettings();
            SiteSettings siteSettings = new SiteSettings()
            {
                AllowedFileTypes = "jpg, png,      gif"
            };

            // Act
            SettingsViewModel model = new SettingsViewModel(appSettings, siteSettings);

            // Assert
            Assert.That(model.AllowedFileTypes, Is.EqualTo("jpg,png,gif"));
        }
示例#26
0
        public void Setup()
        {
            _container = new MocksAndStubsContainer();

            _applicationSettings = _container.ApplicationSettings;
            _siteSettings = _container.SettingsService.GetSiteSettings();
            _emailClientMock = _container.EmailClient;
        }
		public void constructor_should_convert_applicationsettings_and_sitesettings_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
			};

			SiteSettings siteSettings = new SiteSettings()
			{
				AllowedFileTypes = "jpg,png,gif",
				AllowUserSignup = true,
				IsRecaptchaEnabled = true,
				MarkupType = "markuptype",
				RecaptchaPrivateKey = "privatekey",
				RecaptchaPublicKey = "publickey",
				SiteName = "sitename",
				SiteUrl = "siteurl",
				Theme = "theme",
				OverwriteExistingFiles = true,
				HeadContent = "head content",
				MenuMarkup = "menu markup"
			};

			
			// Act
			SettingsViewModel model = new SettingsViewModel(appSettings, siteSettings);

			// 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.AllowedFileTypes, Is.EqualTo(siteSettings.AllowedFileTypes));
			Assert.That(model.AllowUserSignup, Is.EqualTo(siteSettings.AllowUserSignup));
			Assert.That(model.IsRecaptchaEnabled, Is.EqualTo(siteSettings.IsRecaptchaEnabled));
			Assert.That(model.MarkupType, Is.EqualTo(siteSettings.MarkupType));
			Assert.That(model.RecaptchaPrivateKey, Is.EqualTo(siteSettings.RecaptchaPrivateKey));
			Assert.That(model.RecaptchaPublicKey, Is.EqualTo(siteSettings.RecaptchaPublicKey));
			Assert.That(model.SiteName, Is.EqualTo(siteSettings.SiteName));
			Assert.That(model.SiteUrl, Is.EqualTo(siteSettings.SiteUrl));
			Assert.That(model.Theme, Is.EqualTo(siteSettings.Theme));
			Assert.That(model.OverwriteExistingFiles, Is.EqualTo(siteSettings.OverwriteExistingFiles));
			Assert.That(model.HeadContent, Is.EqualTo(siteSettings.HeadContent));
			Assert.That(model.MenuMarkup, Is.EqualTo(siteSettings.MenuMarkup));
		}
示例#28
0
		public void SaveSiteSettings(SiteSettings settings)
		{
			SiteSettings = settings;
		}
示例#29
0
		public void Setup()
		{
			_applicationSettings = new ApplicationSettings();
			_siteSettings = new SiteSettings();
			_parser = new CreoleParser(_applicationSettings, _siteSettings);
		}
		public void constructor_should_remove_spaces_from_sitesettings_allow_file_types()
		{
			// Arrange
			ApplicationSettings appSettings = new ApplicationSettings();
			SiteSettings siteSettings = new SiteSettings()
			{
				AllowedFileTypes = "jpg, png,      gif"
			};


			// Act
			SettingsViewModel model = new SettingsViewModel(appSettings, siteSettings);

			// Assert
			Assert.That(model.AllowedFileTypes, Is.EqualTo("jpg,png,gif"));
		}