public void Correctly_drops_connections() { string assembly = SqlDatabaseManager.SQL_FILE_ASSEMBLY; string sqlFile = string.Format(SqlDatabaseManager.SQL_FILE_TEMPLATE, "DropConnections"); ConnectionSettings settings = new ConnectionSettings("server", "MyDatabase", true, null, null); MockRepository mocks = new MockRepository(); ITaskObserver taskObserver = mocks.CreateMock <ITaskObserver>(); IResourceFileLocator fileLocator = mocks.CreateMock <IResourceFileLocator>(); ITokenReplacer replacer = mocks.CreateMock <ITokenReplacer>(); IQueryExecutor queryExecutor = mocks.CreateMock <IQueryExecutor>(); using (mocks.Record()) { taskObserver.Log("Dropping connections for database MyDatabase\n"); Expect.Call(fileLocator.ReadTextFile(assembly, sqlFile)).Return("Unformatted SQL"); replacer.Text = "Unformatted SQL"; replacer.Replace("DatabaseName", "MyDatabase"); Expect.Call(replacer.Text).Return("Formatted SQL"); queryExecutor.ExecuteNonQuery(settings, "Formatted SQL", false); } using (mocks.Playback()) { IDatabaseConnectionDropper dropper = new DatabaseConnectionDropper(fileLocator, replacer, queryExecutor); dropper.Drop(settings, taskObserver); } mocks.VerifyAll(); }
public XmlTemplate( [NotNull] XmlDeclarationParser xmlDeclarationParser, [NotNull] ITemplateLoader templateLoader, [NotNull] ITemplatePreprocessor templatePreprocessor, [NotNull] ITokenReplacer tokenReplacer, [NotNull] TemplatePreferencesLoader templatePreferencesLoader) { if (xmlDeclarationParser == null) { throw new ArgumentNullException(nameof(xmlDeclarationParser)); } if (templateLoader == null) { throw new ArgumentNullException(nameof(templateLoader)); } if (templatePreprocessor == null) { throw new ArgumentNullException(nameof(templatePreprocessor)); } if (tokenReplacer == null) { throw new ArgumentNullException(nameof(tokenReplacer)); } if (templatePreferencesLoader == null) { throw new ArgumentNullException(nameof(templatePreferencesLoader)); } _xmlDeclarationParser = xmlDeclarationParser; _templateLoader = templateLoader; _templatePreprocessor = templatePreprocessor; _tokenReplacer = tokenReplacer; _templatePreferencesLoader = templatePreferencesLoader; }
public LoadBalancerBodyView(IApplicationInstanceContext context, IResourceFileLocator fileLocator, ITokenReplacer replacer, IAdministratorSecurityChecker securityChecker) { _context = context; _fileLocator = fileLocator; _replacer = replacer; _securityChecker = securityChecker; }
public LoadBalancerBodyView(IApplicationInstanceContext context, IResourceFileLocator fileLocator, ITokenReplacer replacer, IAdministratorSecurityChecker securityChecker) { _context = context; _fileLocator = fileLocator; _replacer = replacer; _securityChecker = securityChecker; }
public void Correctly_build_menu_view() { MockRepository mocks = new MockRepository(); IResourceFileLocator locator = mocks.CreateMock <IResourceFileLocator>(); ITokenReplacer replacer = mocks.CreateMock <ITokenReplacer>(); using (mocks.Record()) { string htmlTemplate = "||APPLICATION_URL|| ||CACHE_URL|| ||ASSEMBLY_URL|| ||LOADBALANCER_URL|| ||DISABLE_URL||"; Expect.Call(locator.ReadTextFile("Tarantino.Core", MenuView.MenuTemplate)).Return(htmlTemplate); replacer.Text = htmlTemplate; replacer.Replace("APPLICATION_URL", "Tarantino.WebManagement.Application.axd"); replacer.Replace("CACHE_URL", "Tarantino.WebManagement.Cache.axd"); replacer.Replace("ASSEMBLY_URL", "Tarantino.WebManagement.Assemblies.axd"); replacer.Replace("LOADBALANCER_URL", "Tarantino.WebManagement.LoadBalancer.axd"); replacer.Replace("DISABLE_URL", "Tarantino.WebManagement.DisableSSL.axd"); Expect.Call(replacer.Text).Return("fully formatted html"); } using (mocks.Playback()) { IMenuView menuView = new MenuView(locator, replacer); string html = menuView.BuildHtml(); Assert.That(html, Is.EqualTo("fully formatted html")); } }
/// <summary> /// Initializes a new instance of the <see cref="MySqlDatabaseService" /> class. /// </summary> /// <param name="configurationService">The configuration service.</param> /// <param name="fileService">The file service to use</param> /// <param name="tokenReplacer">The token replacer to use.</param> public MySqlDatabaseService( IConfigurationService configurationService, IFileService fileService, ITokenReplacer tokenReplacer) : base(configurationService, fileService, tokenReplacer) { }
public ApplicationListingBodyView(IAdministratorSecurityChecker securityChecker, IApplicationInstanceRepository applicationInstanceRepository, IResourceFileLocator fileLocator, ITokenReplacer replacer, IApplicationListingRowView applicationListingRowView) { this.checker = securityChecker; this.applicationInstanceRepository = applicationInstanceRepository; this.fileLocator = fileLocator; this.replacer = replacer; this.applicationListingRowView = applicationListingRowView; }
public ApplicationListingBodyView(IAdministratorSecurityChecker securityChecker, IApplicationInstanceRepository applicationInstanceRepository, IResourceFileLocator fileLocator, ITokenReplacer replacer, IApplicationListingRowView applicationListingRowView) { this.checker = securityChecker; this.applicationInstanceRepository = applicationInstanceRepository; this.fileLocator = fileLocator; this.replacer = replacer; this.applicationListingRowView = applicationListingRowView; }
/// <summary> /// Initializes a new instance of the <see cref="DatabaseServiceBase" /> class. /// </summary> /// <param name="configurationService">The configuration service.</param> /// <param name="fileService">The file service to use for file operations.</param> /// <param name="tokenReplacer">The token Replacer.</param> public DatabaseServiceBase( IConfigurationService configurationService, IFileService fileService, ITokenReplacer tokenReplacer) { this.ConfigurationService = configurationService; this.FileService = fileService; this.tokenReplacer = tokenReplacer; }
/// <summary> /// Initializes a new instance of the <see cref="ScriptService" /> class. /// </summary> /// <param name="fileService">the File service to use for file requests.</param> /// <param name="tokenReplacer">The token replacer to use for script processing.</param> /// <param name="configurationService">The configuration service to use for processing.</param> public ScriptService( IFileService fileService, ITokenReplacer tokenReplacer, IConfigurationService configurationService) { this.fileService = fileService; this.tokenReplacer = tokenReplacer; this.configurationService = configurationService; }
/// <summary> /// Initializes a new instance of the <see cref="BogusDatabaseMock" /> class. /// </summary> /// <param name="configurationService">The configuration service.</param> /// <param name="fileService">The file service to use for file operations.</param> /// <param name="tokenReplacer">The token replacer to use.</param> public BogusDatabaseMock( IConfigurationService configurationService, IFileService fileService, ITokenReplacer tokenReplacer) : base(configurationService, fileService, tokenReplacer) { this.ScriptsRun = new List <string>(); this.ScriptsRunNames = new List <string>(); }
/// <summary> /// Initializes a new instance of the <see cref="DatabaseServiceBase"/> class. /// </summary> /// <param name="configurationService"> /// The configuration service. /// </param> /// <param name="fileService"> /// The file service to use for file operations. /// </param> /// <param name="tokenReplacer"> /// The token Replacer. /// </param> public DatabaseServiceBase(IConfigurationService configurationService, IFileService fileService, ITokenReplacer tokenReplacer) { if (log.IsDebugEnabled) { log.Debug(LogUtility.GetContext(configurationService, fileService, tokenReplacer)); } this.ConfigurationService = configurationService; this.FileService = fileService; this.tokenReplacer = tokenReplacer; }
/// <summary> /// Initializes a new instance of the <see cref="ScriptService"/> class. /// </summary> /// <param name="databaseService"> /// The database service. /// </param> /// <param name="fileService"> /// the File service to use for file requests. /// </param> /// <param name="tokenReplacer"> /// The token replacer to use for script processing. /// </param> /// <param name="configurationService"> /// The configuration service to use for processing. /// </param> public ScriptService(IDatabaseService databaseService, IFileService fileService, ITokenReplacer tokenReplacer, IConfigurationService configurationService) { if (log.IsDebugEnabled) { log.Debug(LogUtility.GetContext(databaseService, fileService, tokenReplacer, configurationService)); } this.databaseService = databaseService; this.fileService = fileService; this.tokenReplacer = tokenReplacer; this.configurationService = configurationService; }
public StringProperty( Expression expression, Localizable name, string initial, IPropertyConfiguration configuration, ITokenReplacer tokenReplacer, IValidationContext validationContext, Func <string> getter, Action <string> setter, IEnumerable <IValidator <string> > validators) : base(expression, name, initial, configuration, validationContext, getter, setter, validators) { _tokenReplacer = tokenReplacer; }
public void AddTokenReplacer(XmlNode configNode) { Assert.ArgumentNotNull(configNode, "configNode"); string name = XmlUtil.GetAttribute("name", configNode); if (!string.IsNullOrEmpty(name)) { ITokenReplacer obj = Factory.CreateObject(configNode, true) as ITokenReplacer; if (obj != null) { this.TokenReplacers[name] = obj; } } }
public void Correctly_returns_html_for_page_for_an_administrator() { List <ApplicationInstance> applicationList = new List <ApplicationInstance>(); //application group 1 applicationList.Add(new ApplicationInstance()); applicationList[0].MaintenanceHostHeader = "1"; applicationList.Add(new ApplicationInstance()); applicationList[1].MaintenanceHostHeader = "1"; //application group 2 applicationList.Add(new ApplicationInstance()); applicationList[2].MaintenanceHostHeader = "2"; applicationList.Add(new ApplicationInstance()); applicationList[3].MaintenanceHostHeader = "2"; MockRepository mocks = new MockRepository(); IApplicationInstanceRepository repository = mocks.CreateMock <IApplicationInstanceRepository>(); IResourceFileLocator fileLocator = mocks.CreateMock <IResourceFileLocator>(); ITokenReplacer replacer = mocks.CreateMock <ITokenReplacer>(); IAdministratorSecurityChecker securityChecker = mocks.CreateMock <IAdministratorSecurityChecker>(); IApplicationListingRowView applicationListingRowView = mocks.CreateMock <IApplicationListingRowView>(); using (mocks.Record()) { Expect.Call(securityChecker.IsCurrentUserAdministrator()).Return(true); Expect.Call(repository.GetAll()).Return(applicationList); Expect.Call(fileLocator.ReadTextFile("Tarantino.Core", ApplicationListingBodyView.BodyTemplate)).Return("body template"); replacer.Text = "body template"; Expect.Call(applicationListingRowView.BuildFirstRowHtml(applicationList[0], 2)).Return("1"); Expect.Call(applicationListingRowView.BuildMRowHtml(applicationList[1])).Return("2"); Expect.Call(applicationListingRowView.BuildFirstRowHtml(applicationList[2], 2)).Return("3"); Expect.Call(applicationListingRowView.BuildMRowHtml(applicationList[3])).Return("4"); replacer.Replace("ROWS", "1234"); Expect.Call(replacer.Text).Return("formatted HTML"); } using (mocks.Playback()) { IApplicationListingBodyView view = new ApplicationListingBodyView(securityChecker, repository, fileLocator, replacer, applicationListingRowView); string html = view.BuildHtml(); Assert.That(html, Is.EqualTo("formatted HTML")); } mocks.VerifyAll(); }
public void Correctly_returns_html_for_error_authenticated_page_with_disabled_instance() { string errorMessage = "An error has occured!"; string bodyTemplate = "body template"; ApplicationInstance instance = new ApplicationInstance(); instance.MachineName = "MyMachine"; instance.AvailableForLoadBalancing = false; MockRepository mocks = new MockRepository(); IApplicationInstanceContext context = mocks.CreateMock <IApplicationInstanceContext>(); IResourceFileLocator fileLocator = mocks.CreateMock <IResourceFileLocator>(); ITokenReplacer replacer = mocks.CreateMock <ITokenReplacer>(); IAdministratorSecurityChecker securityChecker = mocks.CreateMock <IAdministratorSecurityChecker>(); using (mocks.Record()) { Expect.Call(securityChecker.IsCurrentUserAdministrator()).Return(true); Expect.Call(context.GetCurrent()).Return(instance); Expect.Call(fileLocator.ReadTextFile("Tarantino.Core", LoadBalancerBodyView.LoadBalancerBodyTemplate)).Return(bodyTemplate); replacer.Text = bodyTemplate; replacer.Replace("ERROR_MESSAGE", errorMessage); replacer.Replace("CURRENT_STATE", "disabled"); replacer.Replace("MACHINE", "MyMachine"); replacer.Replace("CHANGE_STATE_LINK", "<a href=\"?enabled=True\">enable</a>"); Expect.Call(replacer.Text).Return("formatted HTML"); } using (mocks.Playback()) { ILoadBalancerBodyView view = new LoadBalancerBodyView(context, fileLocator, replacer, securityChecker); string html = view.BuildHtml(errorMessage); Assert.That(html, Is.EqualTo("formatted HTML")); } }
public void Builder_Should_return_a_friendly_not_suthorized_message_for_non_administrators() { MockRepository mocks = new MockRepository(); ITokenReplacer replacer = mocks.CreateMock <ITokenReplacer>(); IAdministratorSecurityChecker securityChecker = mocks.CreateMock <IAdministratorSecurityChecker>(); using (mocks.Record()) { Expect.Call(securityChecker.IsCurrentUserAdministrator()).Return(false); replacer.Text = "Unauthorized request."; Expect.Call(replacer.Text).Return("formatted HTML"); } using (mocks.Playback()) { ApplicationListingBodyView view = new ApplicationListingBodyView(securityChecker, null, null, replacer, null); string html = view.BuildHtml(); Assert.That(html, Is.EqualTo("formatted HTML")); } mocks.VerifyAll(); }
public void View_should_build_html_for_row_one() { ApplicationInstance instance = new ApplicationInstance(); instance.MaintenanceHostHeader = "1"; instance.MachineName = "2"; instance.Id = Guid.NewGuid(); MockRepository mocks = new MockRepository(); IResourceFileLocator fileLocator = mocks.CreateMock <IResourceFileLocator>(); ITokenReplacer tokenReplacer = mocks.CreateMock <ITokenReplacer>(); using (mocks.Record()) { Expect.Call(fileLocator.ReadTextFile("Tarantino.Core", ApplicationListingBodyView.Row1Fragment)).Return( "template"); tokenReplacer.Text = "template"; tokenReplacer.Replace("INSTANCE_COUNT", "2"); tokenReplacer.Replace("INSTANCE_ID", instance.Id.ToString()); tokenReplacer.Replace("MAINTANANCE_HOST_HEADER", instance.MaintenanceHostHeader); tokenReplacer.Replace("MAINTANANCE_STATUS", instance.DownForMaintenance ? "Offline" : "Online"); tokenReplacer.Replace("MACHINE_NAME", instance.MachineName); tokenReplacer.Replace("LOAD_BALANCE_STATUS", instance.AvailableForLoadBalancing ? "Online" : "Offline"); tokenReplacer.Replace("NEW_LOAD_BALANCE_STATUS", (!instance.AvailableForLoadBalancing).ToString()); tokenReplacer.Replace("VERSION", instance.Version); tokenReplacer.Replace("HOST_HEADER", instance.UniqueHostHeader); Expect.Call(tokenReplacer.Text).Return("html"); } using (mocks.Playback()) { ApplicationListingRowView view = new ApplicationListingRowView(fileLocator, tokenReplacer); string html = view.BuildFirstRowHtml(instance, 2); Assert.That(html, Is.EqualTo("html")); } mocks.VerifyAll(); }
public void Correctly_renders_page_view() { string cssText = "css stuff"; MockRepository mocks = new MockRepository(); IResourceFileLocator fileLocator = mocks.CreateMock <IResourceFileLocator>(); ITokenReplacer replacer = mocks.CreateMock <ITokenReplacer>(); IMenuView menuView = mocks.CreateMock <IMenuView>(); using (mocks.Record()) { string htmlTemplate = "||CSS|| ||MENU|| ||BODY||"; Expect.Call(fileLocator.ReadTextFile("Tarantino.Core", PageView.PageTemplate)).Return(htmlTemplate); replacer.Text = htmlTemplate; Expect.Call(fileLocator.ReadTextFile("Tarantino.Core", PageView.StylesheetTemplate)).Return(cssText); replacer.Replace("CSS", cssText); Expect.Call(menuView.BuildHtml()).Return("menu stuff"); replacer.Replace("MENU", "menu stuff"); replacer.Replace("BODY", "body stuff"); Expect.Call(replacer.Text).Return("page content"); } using (mocks.Playback()) { IPageView pageView = new PageView(fileLocator, menuView, replacer); string html = pageView.BuildHtml("body stuff"); Assert.That(html, Is.EqualTo("page content")); } }
public PageView(IResourceFileLocator fileLocator, IMenuView menuView, ITokenReplacer replacer) { _fileLocator = fileLocator; _menuView = menuView; _replacer = replacer; }
public DatabaseConnectionDropper(IResourceFileLocator fileLocator, ITokenReplacer replacer, IQueryExecutor executor) { _fileLocator = fileLocator; _replacer = replacer; _executor = executor; }
private IProperty CreateStringProperty(object @object, string initial, PropertyInfo property, Localizable name, FormType form, ITokenReplacer tokenReplacer) { return(new StringProperty( CreateExression(property), name, initial, GetConfiguration(property, form), tokenReplacer, _validationContext, () => (string)property.GetValue(@object), value => property.SetValue(@object, value), GetAttributes <IValidator <string> >(property))); }
public DatabaseConnectionDropper(IResourceFileLocator fileLocator, ITokenReplacer replacer, IQueryExecutor executor) { _fileLocator = fileLocator; _replacer = replacer; _executor = executor; }
public PageView(IResourceFileLocator fileLocator, IMenuView menuView, ITokenReplacer replacer) { _fileLocator = fileLocator; _menuView = menuView; _replacer = replacer; }
public MenuView(IResourceFileLocator resourceFileLocator, ITokenReplacer replacer) { _resourceFileLocator = resourceFileLocator; _replacer = replacer; }
public MenuView(IResourceFileLocator resourceFileLocator, ITokenReplacer replacer) { _resourceFileLocator = resourceFileLocator; _replacer = replacer; }
public AssemblingContext(FormType type, ITokenReplacer tokenReplacer = null) { FormType = type; TokenReplacer = tokenReplacer; }
public ApplicationListingRowView(IResourceFileLocator fileLocator, ITokenReplacer tokenReplacer) { this.fileLocator = fileLocator; this.tokenReplacer = tokenReplacer; }
public ExcelImporter(IResourceFileLocator fileLocator, IQueryExecutor queryExecutor, ITokenReplacer tokenReplacer) { _fileLocator = fileLocator; _queryExecutor = queryExecutor; _tokenReplacer = tokenReplacer; }
public InjectionViewModel(InjectionConfigurationViewModel injectionConfigurationViewModel, GamePackage package) { _injectionConfigurationViewModel = injectionConfigurationViewModel; _package = package; _tokenReplacer = new TokenReplacer(new ApplicationFilePathTokenReplacingPolicy(() => _package.Game?.FilePath ?? string.Empty)); }
public ExcelImporter(IResourceFileLocator fileLocator, IQueryExecutor queryExecutor, ITokenReplacer tokenReplacer) { _fileLocator = fileLocator; _queryExecutor = queryExecutor; _tokenReplacer = tokenReplacer; }
public ApplicationListingRowView(IResourceFileLocator fileLocator, ITokenReplacer tokenReplacer) { this.fileLocator = fileLocator; this.tokenReplacer = tokenReplacer; }