public void Setup() { _container = new MocksAndStubsContainer(); _installerRepository = _container.InstallerRepository; _installationService = _container.InstallationService; }
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; }
public void Setup() { _container = new MocksAndStubsContainer(); _applicationSettings = _container.ApplicationSettings; _applicationSettings.Installed = false; _settingsService = _container.SettingsService; _userService = _container.UserService; _configReaderWriter = _container.ConfigReaderWriter; _repositoryFactory = _container.RepositoryFactory; _installationService = _container.InstallationService; _databaseTester = _container.DatabaseTester; _installerRepository = _container.InstallerRepository; _installController = new InstallController(_applicationSettings, _configReaderWriter, _installationService, _databaseTester); }
/// <summary> /// Displays the second step in the installation wizard (connection strings and site url/name). /// </summary> public ActionResult Step2(string language) { // Persist the language change now that we know the web.config can be written to. if (!string.IsNullOrEmpty(language)) { Thread.CurrentThread.CurrentUICulture = new CultureInfo(language); _configReaderWriter.UpdateLanguage(language); } var settingsModel = new SettingsViewModel(); var installationService = new InstallationService(); IEnumerable<RepositoryInfo> supportedDatabases = installationService.GetSupportedDatabases(); settingsModel.SetSupportedDatabases(supportedDatabases); return View(settingsModel); }
/// <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"); ConfigReaderWriter = new ConfigReaderWriterStub(); // Cache MemoryCache = useCacheMock ? new CacheMock() : CacheMock.RoadkillCache; ListCache = new ListCache(ApplicationSettings, MemoryCache); SiteCache = new SiteCache(MemoryCache); PageViewModelCache = new PageViewModelCache(ApplicationSettings, MemoryCache); // Repositories SettingsRepository = new SettingsRepositoryMock(); SettingsRepository.SiteSettings = new SiteSettings(); SettingsRepository.SiteSettings.MarkupType = "Creole"; UserRepository = new UserRepositoryMock(); PageRepository = new PageRepositoryMock(); InstallerRepository = new InstallerRepositoryMock(); RepositoryFactory = new RepositoryFactoryMock() { SettingsRepository = SettingsRepository, UserRepository = UserRepository, PageRepository = PageRepository, InstallerRepository = InstallerRepository }; DatabaseTester = new DatabaseTesterMock(); // Plugins PluginFactory = new PluginFactoryMock(); MarkupConverter = new MarkupConverter(ApplicationSettings, SettingsRepository, PageRepository, PluginFactory); // Services // Dependencies for PageService. Be careful to make sure the class using this Container isn't testing the mock. SettingsService = new SettingsService(RepositoryFactory, ApplicationSettings); UserService = new UserServiceMock(ApplicationSettings, UserRepository); UserContext = new UserContext(UserService); SearchService = new SearchServiceMock(ApplicationSettings, SettingsRepository, PageRepository, PluginFactory); SearchService.PageContents = PageRepository.PageContents; SearchService.Pages = PageRepository.Pages; HistoryService = new PageHistoryService(ApplicationSettings, SettingsRepository, PageRepository, UserContext, PageViewModelCache, PluginFactory); FileService = new FileServiceMock(); PageService = new PageService(ApplicationSettings, SettingsRepository, PageRepository, SearchService, HistoryService, UserContext, ListCache, PageViewModelCache, SiteCache, PluginFactory); StructureMapContainer = new Container(x => { x.AddRegistry(new TestsRegistry(this)); }); Locator = new StructureMapServiceLocator(StructureMapContainer, false); InstallationService = new InstallationService((databaseName, connectionString) => { InstallerRepository.DatabaseName = databaseName; InstallerRepository.ConnectionString = connectionString; return InstallerRepository; }, Locator); // EmailTemplates EmailClient = new EmailClientMock(); }