Provides common tasks for changing the Roadkill application settings.
Inheritance: Roadkill.Core.Services.ServiceBase
		public void Setup()
		{
			_container = new MocksAndStubsContainer();	

			_applicationSettings = _container.ApplicationSettings;
			_context = _container.UserContext;

			_settingsRepository = _container.SettingsRepository;
			_userRepository = _container.UserRepository;
			_pageRepository = _container.PageRepository;

			_settingsService = _container.SettingsService;
			_userService = _container.UserService;
			_pageCache = _container.PageViewModelCache;
			_listCache = _container.ListCache;
			_siteCache = _container.SiteCache;
			_cache = _container.MemoryCache;
			_container.ClearCache();

			_pageService = _container.PageService;
			_wikiImporter = new WikiImporterMock();
			_pluginFactory = _container.PluginFactory;
			_searchService = _container.SearchService;

			// There's no point mocking WikiExporter (and turning it into an interface) as 
			// a lot of usefulness of these tests would be lost when creating fake Streams and zip files.
			_wikiExporter = new WikiExporter(_applicationSettings, _pageService, _settingsRepository, _pageRepository, _userRepository, _pluginFactory);
			_wikiExporter.ExportFolder = AppDomain.CurrentDomain.BaseDirectory;

			_toolsController = new ToolsController(_applicationSettings, _userService, _settingsService, _pageService,
													_searchService, _context, _listCache, _pageCache, _wikiImporter, 
													_pluginFactory, _wikiExporter);
		}
		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;
			_userService = _container.UserService;
			_historyService = _container.HistoryService;
			_pageService = _container.PageService;

			_wikiController = new WikiController(_applicationSettings, _userService, _pageService, _context, _settingsService);
			_wikiController.SetFakeControllerContext("~/wiki/index/1");

			// HtmlHelper setup
			var viewDataDictionary = new ViewDataDictionary();
			_viewContext = new ViewContext(_wikiController.ControllerContext, new Mock<IView>().Object, viewDataDictionary, new TempDataDictionary(), new StringWriter());
			var mockViewDataContainer = new Mock<IViewDataContainer>();
			mockViewDataContainer.Setup(v => v.ViewData).Returns(viewDataDictionary);

			_htmlHelper = new HtmlHelper(_viewContext, mockViewDataContainer.Object);
		}
        /// <summary>
        /// Creates a new instance of MocksAndStubsContainer.
        /// </summary>
        /// <param name="useCacheMock">The 'Roadkill' MemoryCache is used by default, but as this is static it can have problems with 
        /// the test runner unless you clear the Container.MemoryCache on setup each time, but then doing that doesn't give a realistic 
        /// reflection of how the MemoryCache is used inside an ASP.NET environment.</param>
        public MocksAndStubsContainer(bool useCacheMock = false)
        {
            ApplicationSettings = new ApplicationSettings();
            ApplicationSettings.Installed = true;
            ApplicationSettings.AttachmentsFolder = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "attachments");

            // Cache
            MemoryCache = useCacheMock ? new CacheMock() : CacheMock.RoadkillCache;
            ListCache = new ListCache(ApplicationSettings, MemoryCache);
            SiteCache = new SiteCache(ApplicationSettings, MemoryCache);
            PageViewModelCache = new PageViewModelCache(ApplicationSettings, MemoryCache);

            // Repository
            Repository = new RepositoryMock();
            Repository.SiteSettings = new SiteSettings();
            Repository.SiteSettings.MarkupType = "Creole";

            PluginFactory = new PluginFactoryMock();
            MarkupConverter = new MarkupConverter(ApplicationSettings, Repository, PluginFactory);

            // Dependencies for PageService. Be careful to make sure the class using this Container isn't testing the mock.
            SettingsService = new SettingsService(ApplicationSettings, Repository);
            UserService = new UserServiceMock(ApplicationSettings, Repository);
            UserContext = new UserContext(UserService);
            SearchService = new SearchServiceMock(ApplicationSettings, Repository, PluginFactory);
            SearchService.PageContents = Repository.PageContents;
            SearchService.Pages = Repository.Pages;
            HistoryService = new PageHistoryService(ApplicationSettings, Repository, UserContext, PageViewModelCache, PluginFactory);

            PageService = new PageService(ApplicationSettings, Repository, SearchService, HistoryService, UserContext, ListCache, PageViewModelCache, SiteCache, PluginFactory);

            // EmailTemplates
            EmailClient = new EmailClientMock();
        }
示例#4
0
        public UpgradeController(ApplicationSettings settings, IRepository repository, UserServiceBase userService,
			IUserContext context, SettingsService settingsService, ConfigReaderWriter configReaderWriter)
            : base(settings, userService, context, settingsService)
        {
            _repository = repository;
            _configReaderWriter = configReaderWriter;
        }
示例#5
0
		public void Setup()
		{
			_container = new MocksAndStubsContainer();

			_applicationSettings = _container.ApplicationSettings;
			_applicationSettings.ConnectionString = "connstring";
			_context = _container.UserContext;
			_repository = _container.Repository;
			_pluginFactory = _container.PluginFactory;
			_settingsService = _container.SettingsService;
			_userService = _container.UserService;
			_historyService = _container.HistoryService;
			_pageService = _container.PageService;
			_listCache = _container.ListCache;
			_pageViewModelCache = _container.PageViewModelCache;

			// User setup
			_editorUser = new User();
			_editorUser.Id = Guid.NewGuid();
			_editorUser.Email = EditorEmail;
			_editorUser.Username = EditorUsername;
			_editorUser.IsAdmin = false;
			_editorUser.IsEditor = true;

			_adminUser = new User();
			_adminUser.Id = Guid.NewGuid();
			_adminUser.Email = AdminEmail;
			_adminUser.Username = AdminUsername;
			_adminUser.IsAdmin = true;
			_adminUser.IsEditor = true;

			_userService.Users.Add(_editorUser);
			_userService.Users.Add(_adminUser);
			SetUserContext(_adminUser);
		}
 /// <summary>
 /// Constructor for the file manager.
 /// </summary>
 /// <remarks>This action requires editor rights.</remarks>
 public FileManagerController(ApplicationSettings settings, UserServiceBase userManager, IUserContext context,
     SettingsService settingsService, AttachmentFileHandler attachment)
     : base(settings, userManager, context, settingsService)
 {
     _attachmentHandler = attachment;
     _attachmentPathUtil = new AttachmentPathUtil(settings);
 }
示例#7
0
		public void Setup()
		{
			_container = new MocksAndStubsContainer();
			_applicationSettings = _container.ApplicationSettings;
			_settingsService = _container.SettingsService;
			_fileService = new LocalFileService(_applicationSettings, _settingsService);

			try
			{
				// Delete any existing attachments folder
				DirectoryInfo directoryInfo = new DirectoryInfo(_applicationSettings.AttachmentsFolder);
				if (directoryInfo.Exists)
				{
					directoryInfo.Attributes = FileAttributes.Normal;
					directoryInfo.Delete(true);
				}

				Directory.CreateDirectory(_applicationSettings.AttachmentsFolder);
			}
			catch (IOException e)
			{
				Assert.Fail("Unable to delete the attachments folder " + _applicationSettings.AttachmentsFolder + ", does it have a lock/explorer window open, or Mercurial open?" + e.ToString());
			}
			catch (ArgumentException e)
			{
				Assert.Fail("Unable to delete the attachments folder " + _applicationSettings.AttachmentsFolder + ", is EasyMercurial open?" + e.ToString());
			}
		}
		public void Setup()
		{
			_container = new MocksAndStubsContainer();

			_repositoryFactory = _container.RepositoryFactory;
			_settingsRepository = _container.SettingsRepository;
			_settingsService = _container.SettingsService;
		}
示例#9
0
		public RelController(ApplicationSettings settings, UserServiceBase userManager,
			SettingsService settingsService, IRelService relService, SearchService searchService,
			PageHistoryService historyService, IUserContext context)
			: base(settings, userManager, context, settingsService)
		{
			_settingsService = settingsService;
            _relService = relService;
		}
示例#10
0
		public HomeController(ApplicationSettings settings, UserServiceBase userManager, MarkupConverter markupConverter,
			PageService pageService, SearchService searchService, IUserContext context, SettingsService settingsService)
			: base(settings, userManager, context, settingsService) 
		{
			_markupConverter = markupConverter;
			_searchService = searchService;
			PageService = pageService;
		}
示例#11
0
		public void Setup()
		{
			_container = new MocksAndStubsContainer();

			_applicationSettings = _container.ApplicationSettings;
			_repository = _container.Repository;
			_settingsService = _container.SettingsService;
		}
示例#12
0
		public ControllerBase(ApplicationSettings settings, UserServiceBase userService, IUserContext context, 
			SettingsService settingsService)
		{
			ApplicationSettings = settings;
			UserService = userService;
			Context = context;
			SettingsService = settingsService;
		}
示例#13
0
		public SettingsController(ApplicationSettings settings, UserServiceBase userManager, SettingsService settingsService, 
			IUserContext context, SiteCache siteCache, ConfigReaderWriter configReaderWriter)
			: base(settings, userManager, context, settingsService) 
		{
			_settingsService = settingsService;
			_siteCache = siteCache;
			_configReaderWriter = configReaderWriter;
		}
示例#14
0
		public UserController(ApplicationSettings settings, UserServiceBase userManager,
			IUserContext context, SettingsService settingsService, 
			SignupEmail signupEmail, ResetPasswordEmail resetPasswordEmail)
			: base(settings, userManager, context, settingsService) 
		{
			_signupEmail = signupEmail;
			_resetPasswordEmail = resetPasswordEmail;
		}
示例#15
0
		public CacheController(ApplicationSettings settings, UserServiceBase userService,
			SettingsService settingsService, IUserContext context,
			ListCache listCache, PageViewModelCache pageViewModelCache, SiteCache siteCache)
			: base(settings, userService, context, settingsService) 
		{
			_listCache = listCache;
			_pageViewModelCache = pageViewModelCache;
			_siteCache = siteCache;
		}
示例#16
0
        public PagesController(ApplicationSettings settings, UserServiceBase userManager,
			SettingsService settingsService, IPageService pageService, SearchService searchService,
			PageHistoryService historyService, IUserContext context)
            : base(settings, userManager, context, settingsService)
        {
            _settingsService = settingsService;
            _pageService = pageService;
            _searchService = searchService;
            _historyService = historyService;
        }
示例#17
0
		public PluginSettingsController(ApplicationSettings settings, UserServiceBase userService, IUserContext context, 
			SettingsService settingsService, IPluginFactory pluginFactory, IRepository repository, SiteCache siteCache, 
			PageViewModelCache viewModelCache, ListCache listCache)
			: base (settings, userService, context, settingsService)
		{
			_pluginFactory = pluginFactory;
			_repository = repository;
			_siteCache = siteCache;
			_viewModelCache = viewModelCache;
			_listCache = listCache;
		}
示例#18
0
		public InstallController(ApplicationSettings settings, UserServiceBase userService,
			PageService pageService, SearchService searchService, IRepository respository,
			SettingsService settingsService, IUserContext context, ConfigReaderWriter configReaderWriter)
			: base(settings, userService, context, settingsService) 
		{
			_pageService = pageService;
			_searchService = searchService;
			_repository = respository;
			_settingsService = settingsService;
			_configReaderWriter = configReaderWriter;
		}
示例#19
0
		public void Setup()
		{
			_container = new MocksAndStubsContainer();

			_applicationSettings = _container.ApplicationSettings;
			_context = _container.UserContext;
			_settingsService = _container.SettingsService;
			_userService = _container.UserService;

			_applicationSettings.AdminRoleName = "Admin";
			_applicationSettings.EditorRoleName = "Editor";
		}
		public void Setup()
		{
			_container = new MocksAndStubsContainer();

			_container.SettingsRepository.SiteSettings.PluginLastSaveDate = _pluginLastSavedDate;

			_pluginFactory = _container.PluginFactory;
			_settingsRepository = _container.SettingsRepository;
			_pageRepository = _container.PageRepository;

			_settingsService = _container.SettingsService;
		}
示例#21
0
		public ToolsController(ApplicationSettings settings, UserServiceBase userManager,
			SettingsService settingsService, PageService pageService, SearchService searchService, IUserContext context,
			ListCache listCache, PageViewModelCache pageViewModelCache, IWikiImporter wikiImporter, IPluginFactory pluginFactory, WikiExporter wikiExporter)
			: base(settings, userManager, context, settingsService) 
		{
			_pageService = pageService;
			_searchService = searchService;
			_listCache = listCache;
			_pageViewModelCache = pageViewModelCache;
			_wikiImporter = wikiImporter;			
			_wikiExporter = wikiExporter;
		}
示例#22
0
		/// <summary>
		/// 
		/// </summary>
		/// <param name="applicationSettings">Use solely to detect whether Roadkill is already installed.</param>
		public InstallController(ApplicationSettings applicationSettings, ConfigReaderWriter configReaderWriter, IInstallationService installationService, IDatabaseTester databaseTester)
		{
			_configReaderWriter = configReaderWriter;
			_installationService = installationService;
			_databaseTester = databaseTester;

			ApplicationSettings = applicationSettings;

			// These aren't needed for the installer
			Context = null;
			SettingsService = null;
			UserService = null;
		}
示例#23
0
		public void Setup()
		{
			_container = new MocksAndStubsContainer();

			_applicationSettings = _container.ApplicationSettings;
			_context = _container.UserContext;
			_repository = _container.Repository;
			_settingsService = _container.SettingsService;
			_userService = _container.UserService;
			_pageService = _container.PageService;

			_helpController = new HelpController(_applicationSettings, _userService, _context, _settingsService, _pageService);
		}
        public void Setup()
        {
            _container = new MocksAndStubsContainer();

            _applicationSettings = _container.ApplicationSettings;
            _context = _container.UserContext;
            _repository = _container.Repository;
            _pluginFactory = _container.PluginFactory;
            _settingsService = _container.SettingsService;
            _userService = _container.UserService;

            _specialPagesController = new SpecialPagesController(_applicationSettings, _userService, _context, _settingsService, _pluginFactory);
        }
        public void Setup()
        {
            _container = new MocksAndStubsContainer();

            _applicationSettings = _container.ApplicationSettings;
            _applicationSettings.AttachmentsFolder = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "attachments");
            _context = _container.UserContext;
            _repository = _container.Repository;
            _settingsService = _container.SettingsService;
            _userService = new FormsAuthUserService(_applicationSettings, _repository);
            _configReaderWriter = new ConfigReaderWriterStub();

            _upgradeController = new UpgradeController(_applicationSettings, _repository, _userService, _context, _settingsService, _configReaderWriter);
        }
		public void Setup()
		{
			_container = new MocksAndStubsContainer();

			_applicationSettings = _container.ApplicationSettings;
			_context = _container.UserContext;

			_pageRepository = _container.PageRepository;
			_userRepository = _container.UserRepository;

			_settingsService = _container.SettingsService;
			_userService = _container.UserService;

			_controller = new UserManagementController(_applicationSettings, _userService, _settingsService, _context);
		}
		public void Setup()
		{
			_container = new MocksAndStubsContainer();

			_applicationSettings = _container.ApplicationSettings;
			_applicationSettings.Installed = false;

			_context = _container.UserContext;
			_settingsService = _container.SettingsService;
			_userService = _container.UserService;
			_configReaderWriter = new ConfigReaderWriterStub();
			_activeDirectoryProviderMock = new ActiveDirectoryProviderMock();

			_configTesterController = new ConfigurationTesterController(_applicationSettings, _context, _configReaderWriter, _activeDirectoryProviderMock);
		}
示例#28
0
		public void Setup()
		{
			_container = new MocksAndStubsContainer();

			_applicationSettings = _container.ApplicationSettings;
			_context = _container.UserContext;	
			_pageRepository = _container.PageRepository;
			_pluginFactory = _container.PluginFactory;
			_settingsService = _container.SettingsService;
			_userService = _container.UserService;
			_historyService = _container.HistoryService;
			_pageService = _container.PageService;

			_wikiController = new WikiController(_applicationSettings, _userService, _pageService, _context, _settingsService);
			_wikiController.SetFakeControllerContext();
		}
示例#29
0
		public UserManagementController(ApplicationSettings settings, UserServiceBase userManager,
			SettingsService settingsService, PageService pageService, SearchService searchService, IUserContext context,
			ListCache listCache, PageViewModelCache pageViewModelCache, SiteCache siteCache, IWikiImporter wikiImporter, 
			IRepository repository, IPluginFactory pluginFactory)
			: base(settings, userManager, context, settingsService) 
		{
			_settingsService = settingsService;
			_pageService = pageService;
			_searchService = searchService;
			_listCache = listCache;
			_pageViewModelCache = pageViewModelCache;
			_siteCache = siteCache;
			_wikiImporter = wikiImporter;			
			_repository = repository;
			_pluginFactory = pluginFactory;
		}
示例#30
0
		public void Setup()
		{
			_container = new MocksAndStubsContainer();

			_applicationSettings = _container.ApplicationSettings;
			_context = _container.UserContext;
			_settingsService = _container.SettingsService;
			_userService = _container.UserService;

			_controller = new ControllerBaseStub(_applicationSettings, _userService, _context, _settingsService);
			_controller.SetFakeControllerContext("~/");

			// InstallController
			_configReaderWriter = new ConfigReaderWriterStub();
			_databaseTester = _container.DatabaseTester;
			_installationService = _container.InstallationService;
		}