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); }
public void Setup() { _container = new MocksAndStubsContainer(); _applicationSettings = _container.ApplicationSettings; _siteSettings = _container.SettingsService.GetSiteSettings(); _pluginFactory = _container.PluginFactory; _pageRepository = _container.PageRepository; }
public void Setup() { _container = new MocksAndStubsContainer(); _pluginFactory = _container.PluginFactory; _appSettings = _container.ApplicationSettings; _appSettings.Installed = true; _pageRepository = _container.PageRepository; _settingsRepository = _container.SettingsRepository; _markupConverter = _container.MarkupConverter; _markupConverter.UrlResolver = new UrlResolverMock(); }
public void Setup() { _container = new MocksAndStubsContainer(); _container.SettingsRepository.SiteSettings.PluginLastSaveDate = _pluginLastSavedDate; _pluginFactory = _container.PluginFactory; _settingsRepository = _container.SettingsRepository; _pageRepository = _container.PageRepository; _settingsService = _container.SettingsService; }
public void Setup() { _container = new MocksAndStubsContainer(); _applicationSettings = _container.ApplicationSettings; _context = _container.UserContext; _pageRepository = _container.PageRepository; _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; _settingsRepository = _container.SettingsRepository; _pageRepository = _container.PageRepository; _userRepository = _container.UserRepository; _pageService = _container.PageService; _pluginFactory = _container.PluginFactory; _wikiExporter = new WikiExporter(_applicationSettings, _pageService, _settingsRepository, _pageRepository, _userRepository, _pluginFactory); _wikiExporter.ExportFolder = AppDomain.CurrentDomain.BaseDirectory; }
public void Setup() { _container = new MocksAndStubsContainer(); _applicationSettings = _container.ApplicationSettings; _applicationSettings.UseHtmlWhiteList = true; _applicationSettings.CustomTokensPath = Path.Combine(TestConstants.WEB_PATH, "App_Data", "customvariables.xml"); _settingsRepository = _container.SettingsRepository; _pageRepository = _container.PageRepository; _pluginFactory = _container.PluginFactory; _markupConverter = _container.MarkupConverter; _markupConverter.UrlResolver = new UrlResolverMock(); }
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(); }
public void Setup() { _container = new MocksAndStubsContainer(); _applicationSettings = _container.ApplicationSettings; _settingsRepository = _container.SettingsRepository; _pageRepository = _container.PageRepository; _pluginFactory = _container.PluginFactory; _settingsService = _container.SettingsService; _userService = _container.UserService; _historyService = _container.HistoryService; _markupConverter = _container.MarkupConverter; _searchService = _container.SearchService; // Use a stub instead of the MocksAndStubsContainer's default _contextStub = new UserContextStub(); // Customise the page service so we can verify what was called _pageServiceMock = new Mock<IPageService>(); _pageServiceMock.Setup(x => x.GetMarkupConverter()).Returns(new MarkupConverter(_applicationSettings, _settingsRepository, _pageRepository, _pluginFactory)); _pageServiceMock.Setup(x => x.GetById(It.IsAny<int>(), false)).Returns<int, bool>((int id, bool loadContent) => { Page page = _pageRepository.GetPageById(id); return new PageViewModel(page); }); _pageServiceMock.Setup(x => x.GetById(It.IsAny<int>(), true)).Returns<int,bool>((int id, bool loadContent) => { PageContent content = _pageRepository.GetLatestPageContent(id); if (content != null) return new PageViewModel(content, _markupConverter); else return null; }); _pageServiceMock.Setup(x => x.FindByTag(It.IsAny<string>())); _pageService = _pageServiceMock.Object; _pagesController = new PagesController(_applicationSettings, _userService, _settingsService, _pageService, _searchService, _historyService, _contextStub); _mocksContainer = _pagesController.SetFakeControllerContext(); }
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; }
public void Setup() { _pluginFactory = new PluginFactoryMock(); _pageRepository = new PageRepositoryMock(); _settingsRepository = new SettingsRepositoryMock(); _settingsRepository.SiteSettings = new SiteSettings(); _settingsRepository.SiteSettings.MarkupType = "Markdown"; _userContext = new UserContextStub(); _applicationSettings = new ApplicationSettings(); _applicationSettings.Installed = true; _cache = new CacheMock(); _siteCache = new SiteCache(_cache); _converter = new MarkupConverter(_applicationSettings, _settingsRepository, _pageRepository, _pluginFactory); _menuParser = new MenuParser(_converter, _settingsRepository, _siteCache, _userContext); }
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; _attachmentFileHandler = new AttachmentFileHandler(_applicationSettings,_container.FileService); _fileService = _container.FileService as FileServiceMock; 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()); } _filesController = new FileManagerController(_applicationSettings, _userService, _context, _settingsService, _attachmentFileHandler, _fileService); _mvcMockContainer = _filesController.SetFakeControllerContext(); }
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; _searchService = _container.SearchService; _markupConverter = _container.MarkupConverter; _listCache = _container.ListCache; _siteCache = _container.SiteCache; _pageViewModelCache = _container.PageViewModelCache; _memoryCache = _container.MemoryCache; _homeController = new HomeController(_applicationSettings, _userService, _markupConverter, _pageService, _searchService, _context, _settingsService); _homeController.SetFakeControllerContext(); }
public void Setup() { _container = new MocksAndStubsContainer(true); _applicationSettings = _container.ApplicationSettings; _applicationSettings.UseObjectCache = true; _context = _container.UserContext; _settingsRepository = _container.SettingsRepository; _pageRepository = _container.PageRepository; _pluginFactory = _container.PluginFactory; _settingsService = _container.SettingsService; _userService = _container.UserService; _historyService = _container.HistoryService; _pageService = _container.PageService; _listCache = _container.ListCache; _siteCache = _container.SiteCache; _pageViewModelCache = _container.PageViewModelCache; _memoryCache = _container.MemoryCache; _controller = new PluginSettingsController(_applicationSettings, _userService, _context, _settingsService, _pluginFactory, _settingsRepository, _siteCache, _pageViewModelCache, _listCache); }
public void should_export_siteconfiguration_and_plugin_settings() { // Arrange var settingsRepository = new SettingsRepositoryMock(); settingsRepository.SiteSettings.PluginLastSaveDate = new DateTime(2013, 11, 09, 0, 0, 0); settingsRepository.SiteSettings.AllowedFileTypes = ".exe,.vbscript"; settingsRepository.SiteSettings.MenuMarkup = "markup ```''' \r\n"; // Plugins setup SiteCache siteCache = new SiteCache(new CacheMock()); TextPluginStub plugin1 = new TextPluginStub("fake-plugin1", "fake plugin1", "description 1", "1.1"); plugin1.PluginCache = siteCache; plugin1.Repository = settingsRepository; plugin1.Settings.IsEnabled = true; plugin1.Settings.SetValue("key1", "value1"); plugin1.Settings.SetValue("key2", "value2"); TextPluginStub plugin2 = new TextPluginStub("fake-plugin2", "fake plugin2", "description 2", "2.1"); plugin2.PluginCache = siteCache; plugin2.Repository = settingsRepository; PluginFactoryMock pluginFactory = new PluginFactoryMock(); pluginFactory.TextPlugins.Add(plugin1); pluginFactory.TextPlugins.Add(plugin2); // SqlExportBuilder SqlExportBuilder builder = new SqlExportBuilder(settingsRepository, new UserRepositoryMock(), new PageRepositoryMock(), pluginFactory); builder.IncludeConfiguration = true; builder.IncludePages = false; string expectedSql = ReadEmbeddedResource("expected-siteconfiguration-export.sql"); expectedSql = expectedSql.Replace("{AppVersion}", ApplicationSettings.ProductVersion); // Act string actualSql = builder.Export(); // Assert Assert.That(actualSql, Is.EqualTo(expectedSql), actualSql); }
public void Setup() { _pluginFactory = new PluginFactoryMock(); }
public void Setup() { _pluginFactory = new PluginFactoryMock(); _repositoryMock = new RepositoryMock(); }
public void Setup() { _container = new MocksAndStubsContainer(); _applicationSettings = _container.ApplicationSettings; _applicationSettings.ConnectionString = "connstring"; _context = _container.UserContext; _pageRepository = _container.PageRepository; _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); }