public void GenerateDeployScript_should_generate_correct_script_on_disk()
        {
            var generator = new SqlScriptGenerator();
            SqlScriptingInput input = generator.GetSqlScriptingInput(@"dsql02.ada-dev.nl\v2012", @"SMS");
            input.RootFolder = @"C:\Temp\Generated";

            SqlDeployScriptResult result = generator.GenerateDeployScript(input);
            string template = Assembly.GetExecutingAssembly().GetFileAsString("Research.EndToEndTests.CodeGeneration.SqlScriptGeneratorTester_GenerateDatabaseDeployScript_result.cmd");  

            string content = string.Format(template, result.Schemas, result.Tables, result.Functions, result.StoredProcedures);

            var file = new FileInfoDto
            {
                Path = Path.Combine(input.RootFolder, "Deploy.cmd")
            };
            file.Content = content;

            var fs = new FileSystem();
            Task deleteDirectoryTask = fs.DeleteDirectoryAsync(input.RootFolder);
            deleteDirectoryTask.Wait();

            Task generateFilesTask = fs.GenerateFileAsync(file);
            generateFilesTask.Wait();

            Assert.AreEqual(true, true);
        }
Esempio n. 2
0
 public async Task GenerateFileAsync(FileInfoDto file)
 {
     string folder = await Task.Factory.StartNew(() =>
     {
         return Path.GetDirectoryName(file.Path);
     });
     await CreateDirectoryAsync(folder);
     await MakeFileWritableAsync(file.Path);
     await WriteAllTextAsync(file.Path, file.Content);
 }
Esempio n. 3
0
        public void AddScriptToResult(string rootFolder, string folderName, string schema, string name , StringBuilder fileContent, SqlScriptingResult result)
        {
            string fileName = string.Format("{0}.{1}.sql", schema, name);
            string folderPath = string.IsNullOrWhiteSpace(rootFolder) ? folderName : Path.Combine(rootFolder, folderName);
            string path = Path.Combine(folderPath, fileName);
            var script = new FileInfoDto
            {
                Content = fileContent.ToString(),
                Path = path
            };

            result.Scripts.Add(script);
        }
Esempio n. 4
0
        public void GenerateSprocs()
        {
            string tepmlate = @"
if object_id('dbo.{0}') is not null
begin
	drop procedure dbo.{0}
end
go

create procedure dbo.{0}
	@ProductieOrder bigint
as
begin
	set nocount on

	
end
go

";

            string[] names = {
"Afkeur7060",
"AfkeurRegulier",
"AfkeurVisual",
"DataTracibilityImport",
"FeatureImport",
"FeaturePropertiesImport",
"FeatureRunDataImport",
"PartImport",
"RoutineImport",
"BC3D1",
"BC3D2",
"BC7060",
"BCPMA",
"BCVisual",
"EC3D1",
"EC3D2",
"EC7060",
"ECPMA",
"ECQV",
"ECVisual",
"Meetgegevens",
"Meetgegevens7060",
"MeetgegevensVisual",
"BCQV"
                             };

            var fs = new FileSystem();
            string exportFolder = @"C:\Temp\";
            foreach (string name in names)
            {
                var file = new FileInfoDto
                {
                    Path = "dbo." + Path.Combine(exportFolder, name + ".sql")
                };
                file.Content = string.Format(tepmlate, name);
                Task generateFilesTask = fs.GenerateFileAsync(file);
                generateFilesTask.Wait();
            }      
        }