private void TestDoFunctions(string input, string expected) { IASTNodeFactory nodeFactory = new ASTNodeFactory(); IAParser parser = AParserFactory.CreateInstance(nodeFactory); ASTNodeList aNodes = parser.CreateNodeList(input); IATranslator translator = ATranslatorFactory.CreateInstance(DbTypeName.SqlServer, nodeFactory); ASTNodeList msNodes = translator.Translate(aNodes); string result = msNodes.ToString(); result.Should().BeEquivalentTo(expected); }
public void DoViews(out int totalViews, out int failedViews, IALogger tmpLogger = null) { IALogger logger = tmpLogger ?? new TestLogger(); totalViews = 0; failedViews = 0; List <IViewDefinition> viewDefinitions = new List <IViewDefinition>(); viewDefinitions.AddRange(GetViewsFromAagView()); viewDefinitions.AddRange(GetViewsFromAsysViewThatAreNotInAagView()); ICommands cmd = _dbContext.PowerPlant.CreateCommands(); IDbSchema schema = _dbContext.PowerPlant.CreateDbSchema(); IASTNodeFactory nodeFactory = new ASTNodeFactory(); IAParser parser = AParserFactory.CreateInstance(nodeFactory); if (_dbContext.DbType == DbTypeName.Oracle) { parser.ExpandEmptyStrings = true; } IATranslator translator = ATranslatorFactory.CreateInstance(_dbContext.DbType, nodeFactory); foreach (var view in viewDefinitions) { if (view.DbType != DbTypeName.Any && view.DbType != _dbContext.DbType) { continue; } totalViews++; try { schema.DropView(view.ViewName); CreateView(cmd, parser, translator, view); logger.Write(string.Format("View '{0}' created", view.ViewName)); } catch (Exception ex) { logger.Write(string.Format("ERROR: Can't create view '{0}'", view.ViewName)); logger.Write(ex.Message); failedViews++; } } }