Example #1
0
        public void Test_Run_With_Parameterized_Tokens(string versionFolder, string scriptName)
        {
            //arrange
            var localVersionService = new LocalVersionService(_traceService);

            localVersionService.Init(_testConfiguration.WorkspacePath);

            localVersionService.IncrementMajorVersion(_testConfiguration.WorkspacePath, null);
            _testDataService.CreateScriptFile(Path.Combine(Path.Combine(_testConfiguration.WorkspacePath, versionFolder), $"{scriptName}.sql"), _testDataService.GetSqlForCreateDbObjectWithTokens($"{scriptName}"));

            //act
            var migrationService = _migrationServiceFactory.Create(_testConfiguration.Platform);

            migrationService.Initialize(_testConfiguration.ConnectionString);
            List <KeyValuePair <string, string> > tokens = new List <KeyValuePair <string, string> >
            {
                new KeyValuePair <string, string>("Token1", "Token1Value"),
                new KeyValuePair <string, string>("Token2", "Token2Value"),
                new KeyValuePair <string, string>("Token3", "Token3Value"),
            };

            migrationService.Run(_testConfiguration.WorkspacePath, "v1.00", autoCreateDatabase: true, tokens: tokens);

            //assert
            _testDataService.CheckIfDbObjectExist(_testConfiguration.ConnectionString, $"{scriptName}_Token1Value_Token2Value_Token3Value").ShouldBeTrue();
        }
        public void Test_Run_With_Parameterized_Tokens(string versionFolder, string scriptName)
        {
            //arrange
            var directoryService = new DirectoryService();
            var fileService      = new FileService();
            var workspaceService = new WorkspaceService(_traceService, directoryService, fileService);

            workspaceService.Init(_testConfiguration.WorkspacePath);

            workspaceService.IncrementMajorVersion(_testConfiguration.WorkspacePath, null);
            _testDataService.CreateScriptFile(Path.Combine(Path.Combine(_testConfiguration.WorkspacePath, versionFolder), $"{scriptName}.sql"), _testDataService.GetSqlForCreateDbObjectWithTokens(TEST_DBOBJECTS.DB_OBJECT_1));

            //act
            List <KeyValuePair <string, string> > tokens = new List <KeyValuePair <string, string> >
            {
                new KeyValuePair <string, string>("Token1", "Token1Value"),
                new KeyValuePair <string, string>("Token2", "Token2Value"),
                new KeyValuePair <string, string>("Token3", "Token3Value"),
            };

            var configuration = _testConfiguration.GetFreshConfiguration();

            configuration.Tokens = tokens;
            var migrationService = _migrationServiceFactory.Create(configuration.Platform);

            migrationService.Run();

            //assert
            _testDataService.CheckIfDbObjectExist(_testConfiguration.ConnectionString, $"{TEST_DBOBJECTS.DB_OBJECT_1}_Token1Value_Token2Value_Token3Value").ShouldBeTrue();
        }