示例#1
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);
        }
示例#2
0
		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;
			_repository = _container.Repository;
			_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;
            _context             = _container.UserContext;
            _repository          = _container.Repository;
            _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, _repository, _pluginFactory);
            _wikiExporter.ExportFolder = AppDomain.CurrentDomain.BaseDirectory;

            _toolsController = new ToolsController(_applicationSettings, _userService, _settingsService, _pageService,
                                                   _searchService, _context, _listCache, _pageCache, _wikiImporter,
                                                   _repository, _pluginFactory, _wikiExporter);
        }
        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()
        {
            // WikiController setup (use WikiController as it's the one typically used by views)
            _container = new MocksAndStubsContainer();

            _applicationSettings = _container.ApplicationSettings;
            _context             = _container.UserContext;
            _repository          = _container.Repository;
            _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;
			_applicationSettings.LdapConnectionString = _ldapString;
			_applicationSettings.LdapUsername = _username;
			_applicationSettings.LdapPassword = _password;
			_applicationSettings.AdminRoleName = _adminsGroupName;
			_applicationSettings.EditorRoleName = _editorsGroupName;
			_repository = _container.Repository;

			List<IPrincipalDetails> adminUsers = new List<IPrincipalDetails>();
			adminUsers.Add(new MockPrincipal() { SamAccountName = "admin1" });
			adminUsers.Add(new MockPrincipal() { SamAccountName = "admin2" });

			List<IPrincipalDetails> editorUsers = new List<IPrincipalDetails>();
			editorUsers.Add(new MockPrincipal() { SamAccountName = "editor1" });
			editorUsers.Add(new MockPrincipal() { SamAccountName = "editor2" });

			_adProviderMock = new Mock<IActiveDirectoryProvider>();
			_adProviderMock.Setup(x => x.GetMembers(_domainPath, _username, _password, _adminsGroupName)).Returns(adminUsers);
			_adProviderMock.Setup(x => x.GetMembers(_domainPath, _username, _password, _editorsGroupName)).Returns(editorUsers);

			_userService = new ActiveDirectoryUserService(_applicationSettings, _repository, _adProviderMock.Object);
		}
示例#7
0
		public void Setup()
		{
			_container = new MocksAndStubsContainer();	

			_applicationSettings = _container.ApplicationSettings;
			_context = _container.UserContext;
			_repository = _container.Repository;
			_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 it 
			// a lot of usefulness of these tests would be lost when creating fake Streams and zip files.
			_wikiExporter = new WikiExporter(_applicationSettings, _pageService, _repository, _pluginFactory);
			_wikiExporter.ExportFolder = AppDomain.CurrentDomain.BaseDirectory;

			_toolsController = new ToolsController(_applicationSettings, _userService, _settingsService, _pageService,
													_searchService, _context, _listCache, _pageCache, _wikiImporter, 
													_repository, _pluginFactory, _wikiExporter);
		}
示例#8
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);
		}
示例#9
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());
			}
		}
示例#10
0
		public void Setup()
		{
			_container = new MocksAndStubsContainer();

			_applicationSettings = _container.ApplicationSettings;
			_repository = _container.Repository;
			_settingsService = _container.SettingsService;
		}
示例#11
0
        public void Setup()
        {
            _container = new MocksAndStubsContainer();

            _applicationSettings = _container.ApplicationSettings;
            _siteSettings        = _container.SettingsService.GetSiteSettings();
            _emailClientMock     = _container.EmailClient;
        }
示例#12
0
		public void Setup()
		{
			_container = new MocksAndStubsContainer();

			_applicationSettings = _container.ApplicationSettings;
			_repository = _container.Repository;
			_emailClientMock = _container.EmailClient;
		}
示例#13
0
        public void Setup()
        {
            _container = new MocksAndStubsContainer();

            _applicationSettings = _container.ApplicationSettings;
            _repository          = _container.Repository;
            _emailClientMock     = _container.EmailClient;
        }
示例#14
0
        public void Setup()
        {
            _container = new MocksAndStubsContainer();

            _applicationSettings = _container.ApplicationSettings;
            _repository          = _container.Repository;
            _settingsService     = _container.SettingsService;
        }
示例#15
0
		public void Setup()
		{
			_container = new MocksAndStubsContainer();
			_applicationSettings = _container.ApplicationSettings;
			_repository = _container.Repository;
			_pageService = _container.PageService;
			_pluginFactory = _container.PluginFactory;

			_wikiExporter = new WikiExporter(_applicationSettings, _pageService, _repository, _pluginFactory);
			_wikiExporter.ExportFolder = AppDomain.CurrentDomain.BaseDirectory;
		}
示例#16
0
        public void Setup()
        {
            _container           = new MocksAndStubsContainer();
            _applicationSettings = _container.ApplicationSettings;
            _repository          = _container.Repository;
            _pageService         = _container.PageService;
            _pluginFactory       = _container.PluginFactory;

            _wikiExporter = new WikiExporter(_applicationSettings, _pageService, _repository, _pluginFactory);
            _wikiExporter.ExportFolder = AppDomain.CurrentDomain.BaseDirectory;
        }
        public void Setup()
        {
            _container = new MocksAndStubsContainer();

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

            _applicationSettings.AdminRoleName  = "Admin";
            _applicationSettings.EditorRoleName = "Editor";
        }
示例#18
0
		public void Setup()
		{
			_container = new MocksAndStubsContainer();

			_pluginFactory = _container.PluginFactory;
			_appSettings = _container.ApplicationSettings;
			_appSettings.Installed = true;
			_repository = _container.Repository;
			_markupConverter = _container.MarkupConverter;
			_markupConverter.UrlResolver = new UrlResolverMock();
		}
示例#19
0
        public void Setup()
        {
            _container = new MocksAndStubsContainer();

            _pluginFactory               = _container.PluginFactory;
            _appSettings                 = _container.ApplicationSettings;
            _appSettings.Installed       = true;
            _repository                  = _container.Repository;
            _markupConverter             = _container.MarkupConverter;
            _markupConverter.UrlResolver = new UrlResolverMock();
        }
        public void Setup()
        {
            _container = new MocksAndStubsContainer();

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

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

            _applicationSettings = _container.ApplicationSettings;
            _context = _container.UserContext;
            _repository = _container.Repository;
            _userService = _container.UserService;

            _userService.Users.Add(new User() { Email = "*****@*****.**" });
            _userViewModel = new UserViewModel(_applicationSettings, _userService);
        }
示例#22
0
        public void Setup()
        {
            _container = new MocksAndStubsContainer();

            _applicationSettings = _container.ApplicationSettings;
            _applicationSettings.UseHtmlWhiteList = true;
            _applicationSettings.CustomTokensPath = Path.Combine(Settings.WEB_PATH, "App_Data", "customvariables.xml");

            _pluginFactory               = _container.PluginFactory;
            _repository                  = _container.Repository;
            _markupConverter             = _container.MarkupConverter;
            _markupConverter.UrlResolver = new UrlResolverMock();
        }
        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);
        }
示例#24
0
        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);
        }
示例#25
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);
        }
示例#26
0
		public void Setup()
		{
			_container = new MocksAndStubsContainer();

			_applicationSettings = _container.ApplicationSettings;
			_applicationSettings.UseHtmlWhiteList = true;
			_applicationSettings.CustomTokensPath = Path.Combine(Settings.WEB_PATH, "App_Data", "customvariables.xml");

			_pluginFactory = _container.PluginFactory;
			_repository = _container.Repository;
			_markupConverter = _container.MarkupConverter;
			_markupConverter.UrlResolver = new UrlResolverMock();
		}
示例#27
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;
			_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);
		}
示例#29
0
        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);
        }
        public void Setup()
        {
            _container = new MocksAndStubsContainer();

            _applicationSettings = _container.ApplicationSettings;
            _context             = _container.UserContext;
            _repository          = _container.Repository;
            _userService         = _container.UserService;

            _userService.Users.Add(new User()
            {
                Username = "******"
            });
            _userViewModel = new UserViewModel(_applicationSettings, _userService);
        }
示例#31
0
		public void Setup()
		{
			_container = new MocksAndStubsContainer();

			_applicationSettings = _container.ApplicationSettings;
			_context = _container.UserContext;	
			_repository = _container.Repository;
			_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();
		}
示例#32
0
        public void Setup()
        {
            _container = new MocksAndStubsContainer();

            _applicationSettings = _container.ApplicationSettings;
            _context             = _container.UserContext;
            _repository          = _container.Repository;
            _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();
        }
示例#33
0
		public void Setup()
		{
			_container = new MocksAndStubsContainer();
			_container.ClearCache();

			_applicationSettings = _container.ApplicationSettings;
			_context = _container.UserContext;
			_repository = _container.Repository;
			_settingsService = _container.SettingsService;
			_userService = _container.UserService;
			_pageCache = _container.PageViewModelCache;
			_listCache = _container.ListCache;
			_siteCache = _container.SiteCache;
			_cache = _container.MemoryCache;

			_cacheController = new CacheController(_applicationSettings, _userService, _settingsService, _context, _listCache, _pageCache, _siteCache);
		}
        public void Setup()
        {
            _container = new MocksAndStubsContainer();
            _container.ClearCache();

            _applicationSettings = _container.ApplicationSettings;
            _context             = _container.UserContext;
            _repository          = _container.Repository;
            _settingsService     = _container.SettingsService;
            _userService         = _container.UserService;
            _pageCache           = _container.PageViewModelCache;
            _listCache           = _container.ListCache;
            _siteCache           = _container.SiteCache;
            _cache = _container.MemoryCache;

            _cacheController = new CacheController(_applicationSettings, _userService, _settingsService, _context, _listCache, _pageCache, _siteCache);
        }
示例#35
0
		public void Setup()
		{
			_container = new MocksAndStubsContainer();

			_applicationSettings = _container.ApplicationSettings;
			_context = _container.UserContext;	
			_repository = _container.Repository;
			_userService = _container.UserService;
			_historyService = _container.HistoryService;

			_testUser = new User();
			_testUser.IsActivated = true;
			_testUser.Id = Guid.NewGuid();
			_testUser.Email = AdminEmail;
			_testUser.Username = AdminUsername;
			_userService.Users.Add(_testUser);

			_context.CurrentUser = _testUser.Id.ToString();
		}
示例#36
0
        public void Setup()
        {
            _container = new MocksAndStubsContainer();

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

            _context            = _container.UserContext;
            _repository         = _container.Repository;
            _pluginFactory      = _container.PluginFactory;
            _settingsService    = _container.SettingsService;
            _userService        = _container.UserService;
            _historyService     = _container.HistoryService;
            _pageService        = _container.PageService;
            _searchService      = _container.SearchService;
            _configReaderWriter = new ConfigReaderWriterStub();

            _installController = new InstallController(_applicationSettings, _userService, _pageService, _searchService, _repository, _settingsService, _context, _configReaderWriter);
        }
        public void Setup()
        {
            _container = new MocksAndStubsContainer();

            _applicationSettings = _container.ApplicationSettings;
            _repository          = _container.Repository;
            _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, _repository, _pluginFactory));
            _pageServiceMock.Setup(x => x.GetById(It.IsAny <int>(), false)).Returns <int, bool>((int id, bool loadContent) =>
            {
                Page page = _repository.GetPageById(id);
                return(new PageViewModel(page));
            });
            _pageServiceMock.Setup(x => x.GetById(It.IsAny <int>(), true)).Returns <int, bool>((int id, bool loadContent) =>
            {
                PageContent content = _repository.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()
        {
            _container = new MocksAndStubsContainer();

            _applicationSettings = _container.ApplicationSettings;
            _context             = _container.UserContext;
            _repository          = _container.Repository;
            _userService         = _container.UserService;
            _historyService      = _container.HistoryService;

            _testUser             = new User();
            _testUser.IsActivated = true;
            _testUser.Id          = Guid.NewGuid();
            _testUser.Email       = AdminEmail;
            _testUser.Username    = AdminUsername;
            _userService.Users.Add(_testUser);

            _context.CurrentUser = _testUser.Id.ToString();
        }
        public void Setup()
        {
            _container = new MocksAndStubsContainer();
            _container.ClearCache();

            _applicationSettings = _container.ApplicationSettings;
            _applicationSettings.AttachmentsFolder = AppDomain.CurrentDomain.BaseDirectory;
            _context            = _container.UserContext;
            _repository         = _container.Repository;
            _settingsService    = _container.SettingsService;
            _userService        = _container.UserService;
            _pageCache          = _container.PageViewModelCache;
            _listCache          = _container.ListCache;
            _siteCache          = _container.SiteCache;
            _cache              = _container.MemoryCache;
            _configReaderWriter = new ConfigReaderWriterStub();

            _settingsController = new SettingsController(_applicationSettings, _userService, _settingsService, _context, _siteCache, _configReaderWriter);
        }
示例#40
0
		public void Setup()
		{
			_container = new MocksAndStubsContainer();

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

			_context = _container.UserContext;
			_repository = _container.Repository;
			_pluginFactory = _container.PluginFactory;
			_settingsService = _container.SettingsService;
			_userService = _container.UserService;
			_historyService = _container.HistoryService;
			_pageService = _container.PageService;
			_searchService = _container.SearchService;
			_configReaderWriter = new ConfigReaderWriterStub();

			_installController = new InstallController(_applicationSettings, _userService, _pageService, _searchService, _repository, _settingsService, _context, _configReaderWriter);
		}
示例#41
0
		public void Setup()
		{
			_container = new MocksAndStubsContainer();
			_container.ClearCache();

			_applicationSettings = _container.ApplicationSettings;
			_applicationSettings.AttachmentsFolder = AppDomain.CurrentDomain.BaseDirectory;
			_context = _container.UserContext;
			_repository = _container.Repository;
			_settingsService = _container.SettingsService;
			_userService = _container.UserService;
			_pageCache = _container.PageViewModelCache;
			_listCache = _container.ListCache;
			_siteCache = _container.SiteCache;
			_cache = _container.MemoryCache;
			_configReaderWriter = new ConfigReaderWriterStub();

			_settingsController = new SettingsController(_applicationSettings, _userService, _settingsService, _context, _siteCache, _configReaderWriter);
		}
示例#42
0
        public void Setup()
        {
            _container = new MocksAndStubsContainer();

            _applicationSettings = _container.ApplicationSettings;
            _applicationSettings.AttachmentsFolder = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "attachments");
            _repository      = _container.Repository;
            _settingsService = _container.SettingsService;
            _userService     = _container.UserService;
            _userContext     = _container.UserContext;
            _emailClientMock = _container.EmailClient;

            _userService.AddUser(AdminEmail, AdminUsername, AdminPassword, true, true);
            _userService.Users[0].IsActivated = true;
            _userService.Users[0].Firstname   = "Firstname";
            _userService.Users[0].Lastname    = "LastnameNotSurname";

            _userController   = new UserController(_applicationSettings, _userService, _userContext, _settingsService, null, null);
            _mvcMockContainer = _userController.SetFakeControllerContext();
        }
示例#43
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);
            MvcMockContainer container = _controller.SetFakeControllerContext("~/");

            // Used by InstallController
            _repository = _container.Repository;
            _pluginFactory = _container.PluginFactory;
            _historyService = _container.HistoryService;
            _pageService = _container.PageService;
            _searchService = _container.SearchService;
            _configReaderWriter = new ConfigReaderWriterStub();
        }
示例#44
0
		public void Setup()
		{
			_container = new MocksAndStubsContainer();

			_applicationSettings = _container.ApplicationSettings;
			_applicationSettings.AttachmentsFolder = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "attachments");
			_repository = _container.Repository;
			_settingsService = _container.SettingsService;
			_userService = _container.UserService;
			_userContext = _container.UserContext;
			_emailClientMock = _container.EmailClient;

			_userService.AddUser(AdminEmail, AdminUsername, AdminPassword, true, true);
			_userService.Users[0].IsActivated = true;
			_userService.Users[0].Firstname = "Firstname";
			_userService.Users[0].Lastname = "LastnameNotSurname";

			_userController = new UserController(_applicationSettings, _userService, _userContext, _settingsService, null, null);
			_mvcMockContainer = _userController.SetFakeControllerContext();
		}
        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);
            MvcMockContainer container = _controller.SetFakeControllerContext("~/");

            // Used by InstallController
            _repository         = _container.Repository;
            _pluginFactory      = _container.PluginFactory;
            _historyService     = _container.HistoryService;
            _pageService        = _container.PageService;
            _searchService      = _container.SearchService;
            _configReaderWriter = new ConfigReaderWriterStub();
        }
示例#46
0
        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;
            _repository          = _container.Repository;
            _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()
		{
			_container = new MocksAndStubsContainer(true);

			_applicationSettings = _container.ApplicationSettings;
			_applicationSettings.UseObjectCache = true;
			_context = _container.UserContext;
			_repository = _container.Repository;
			_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, _repository, _siteCache, _pageViewModelCache, _listCache);
		}
        public void Setup()
        {
            _container = new MocksAndStubsContainer(true);

            _applicationSettings = _container.ApplicationSettings;
            _applicationSettings.UseObjectCache = true;
            _context         = _container.UserContext;
            _repository      = _container.Repository;
            _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, _repository, _siteCache, _pageViewModelCache, _listCache);
        }
示例#49
0
		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;
			_repository = _container.Repository;
			_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()
        {
            _container = new MocksAndStubsContainer();

            _applicationSettings   = _container.ApplicationSettings;
            _context               = _container.UserContext;
            _repository            = _container.Repository;
            _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;
            _repository          = _container.Repository;
            _settingsService     = _container.SettingsService;
            _userService         = _container.UserService;
            _pageCache           = _container.PageViewModelCache;
            _listCache           = _container.ListCache;
            _siteCache           = _container.SiteCache;
            _cache = _container.MemoryCache;

            _pageService   = _container.PageService;
            _wikiImporter  = new ScrewTurnImporter(_applicationSettings, _repository);
            _pluginFactory = _container.PluginFactory;
            _searchService = _container.SearchService;

            _controller = new UserManagementController(_applicationSettings, _userService, _settingsService, _pageService,
                                                       _searchService, _context, _listCache, _pageCache, _siteCache, _wikiImporter, _repository, _pluginFactory);
        }
示例#52
0
        public void Setup()
        {
            _container           = new MocksAndStubsContainer();
            _applicationSettings = _container.ApplicationSettings;
            _applicationSettings.LdapConnectionString = _ldapString;
            _applicationSettings.LdapUsername         = _username;
            _applicationSettings.LdapPassword         = _password;
            _applicationSettings.AdminRoleName        = _adminsGroupName;
            _applicationSettings.EditorRoleName       = _editorsGroupName;
            _repository = _container.Repository;

            List <IPrincipalDetails> adminUsers = new List <IPrincipalDetails>();

            adminUsers.Add(new MockPrincipal()
            {
                SamAccountName = "admin1"
            });
            adminUsers.Add(new MockPrincipal()
            {
                SamAccountName = "admin2"
            });

            List <IPrincipalDetails> editorUsers = new List <IPrincipalDetails>();

            editorUsers.Add(new MockPrincipal()
            {
                SamAccountName = "editor1"
            });
            editorUsers.Add(new MockPrincipal()
            {
                SamAccountName = "editor2"
            });

            _adProviderMock = new Mock <IActiveDirectoryProvider>();
            _adProviderMock.Setup(x => x.GetMembers(_domainPath, _username, _password, _adminsGroupName)).Returns(adminUsers);
            _adProviderMock.Setup(x => x.GetMembers(_domainPath, _username, _password, _editorsGroupName)).Returns(editorUsers);

            _userService = new ActiveDirectoryUserService(_applicationSettings, _repository, _adProviderMock.Object);
        }
示例#53
0
		public void Setup()
		{
			_container = new MocksAndStubsContainer();

			_applicationSettings = _container.ApplicationSettings;
			_repository = _container.Repository;
			_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, _repository, _pluginFactory));
			_pageServiceMock.Setup(x => x.GetById(It.IsAny<int>(), false)).Returns<int, bool>((int id, bool loadContent) =>
				{
					Page page = _repository.GetPageById(id);
					return new PageViewModel(page);
				});
			_pageServiceMock.Setup(x => x.GetById(It.IsAny<int>(), true)).Returns<int,bool>((int id, bool loadContent) =>
			{
				PageContent content = _repository.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()
		{
			_container = new MocksAndStubsContainer();

			_applicationSettings = _container.ApplicationSettings;
			_context = _container.UserContext;
			_repository = _container.Repository;
			_settingsService = _container.SettingsService;
			_userService = _container.UserService;
			_pageCache = _container.PageViewModelCache;
			_listCache = _container.ListCache;
			_siteCache = _container.SiteCache;
			_cache = _container.MemoryCache;

			_pageService = _container.PageService;
			_wikiImporter = new ScrewTurnImporter(_applicationSettings, _repository);
			_pluginFactory = _container.PluginFactory;
			_searchService = _container.SearchService;

			_controller = new UserManagementController(_applicationSettings, _userService, _settingsService, _pageService, 
				_searchService, _context, _listCache, _pageCache, _siteCache, _wikiImporter, _repository, _pluginFactory);
		}
示例#55
0
		public void Setup()
		{
			_container = new MocksAndStubsContainer();

			_applicationSettings = _container.ApplicationSettings;
			_context = _container.UserContext;
			_repository = _container.Repository;
			_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();
		}
示例#56
0
        public void Setup()
        {
            _container = new MocksAndStubsContainer();

            _applicationSettings = _container.ApplicationSettings;
            _context             = _container.UserContext;
            _repository          = _container.Repository;
            _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();
        }
示例#57
0
		public void Setup()
		{
			_container = new MocksAndStubsContainer();

			_applicationSettings = _container.ApplicationSettings;
			_context = _container.UserContext;
			_repository = _container.Repository;
			_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();
     _userService = new FormsAuthUserService(_container.ApplicationSettings, _container.Repository);
 }
示例#59
0
        public void Setup()
        {
            _container = new MocksAndStubsContainer();

            _applicationSettings = _container.ApplicationSettings;
            _siteSettings = _container.SettingsService.GetSiteSettings();
            _emailClientMock = _container.EmailClient;
        }
 public void Setup()
 {
     _container   = new MocksAndStubsContainer();
     _userService = new FormsAuthUserService(_container.ApplicationSettings, _container.Repository);
 }