Example #1
0
        private static void SetScriptsFoldersPath(ref ProjectConfigItem projectConfig, ScriptFilesStateType scriptFilesStateType)
        {
            if (projectConfig.DevEnvironment)
            {
                switch (scriptFilesStateType)
                {
                case ScriptFilesStateType.ValidScripts:

                    projectConfig.DevScriptsBaseFolderPath = FileSystemPathUtils.ParsePathVaribles(IntegrationTestsConsts.DevScriptsBaseFolderPath_Normal).Replace("[DBType]", projectConfig.DBType);
                    break;

                case ScriptFilesStateType.MissingFile:

                    projectConfig.DevScriptsBaseFolderPath = FileSystemPathUtils.ParsePathVaribles(IntegrationTestsConsts.DevScriptsBaseFolderPath_MissingFile).Replace("[DBType]", projectConfig.DBType);
                    break;

                case ScriptFilesStateType.ScriptError:

                    projectConfig.DevScriptsBaseFolderPath = FileSystemPathUtils.ParsePathVaribles(IntegrationTestsConsts.DevScriptsBaseFolderPath_ScriptError).Replace("[DBType]", projectConfig.DBType);
                    break;

                case ScriptFilesStateType.IncrementalChanged:

                    projectConfig.DevScriptsBaseFolderPath = FileSystemPathUtils.ParsePathVaribles(IntegrationTestsConsts.DevScriptsBaseFolderPath_ChangedHistoryFiles_Incremental).Replace("[DBType]", projectConfig.DBType);
                    break;

                case ScriptFilesStateType.RepeatableChanged:

                    projectConfig.DevScriptsBaseFolderPath = FileSystemPathUtils.ParsePathVaribles(IntegrationTestsConsts.DevScriptsBaseFolderPath_ChangedHistoryFiles_Repeatable).Replace("[DBType]", projectConfig.DBType);
                    break;

                case ScriptFilesStateType.NoScriptFiles:

                    projectConfig.DevScriptsBaseFolderPath = FileSystemPathUtils.ParsePathVaribles(IntegrationTestsConsts.DevScriptsBaseFolderPath_NoScriptFiles).Replace("[DBType]", projectConfig.DBType);

                    if (!Directory.Exists(projectConfig.IncrementalScriptsFolderPath))
                    {
                        Directory.CreateDirectory(projectConfig.IncrementalScriptsFolderPath);
                    }
                    if (!Directory.Exists(projectConfig.RepeatableScriptsFolderPath))
                    {
                        Directory.CreateDirectory(projectConfig.RepeatableScriptsFolderPath);
                    }
                    if (!Directory.Exists(projectConfig.DevDummyDataScriptsFolderPath))
                    {
                        Directory.CreateDirectory(projectConfig.DevDummyDataScriptsFolderPath);
                    }

                    break;

                default:
                    throw new Exception($"Invalid ScriptFilesStateType: '{scriptFilesStateType}'");
                }
            }
            else
            {
                projectConfig.DeliveryArtifactFolderPath = scriptFilesStateType switch
                {
                    ScriptFilesStateType.ValidScripts => FileSystemPathUtils.ParsePathVaribles(IntegrationTestsConsts.DeliveryArtifactFolderPath_Normal).Replace("[DBType]", projectConfig.DBType),
                    ScriptFilesStateType.MissingFile => FileSystemPathUtils.ParsePathVaribles(IntegrationTestsConsts.DeliveryArtifactFolderPath_MissingFileh).Replace("[DBType]", projectConfig.DBType),
                    ScriptFilesStateType.ScriptError => FileSystemPathUtils.ParsePathVaribles(IntegrationTestsConsts.DeliveryArtifactFolderPath_ScriptError).Replace("[DBType]", projectConfig.DBType),
                    ScriptFilesStateType.IncrementalChanged => FileSystemPathUtils.ParsePathVaribles(IntegrationTestsConsts.DeliveryArtifactFolderPath_ChangedHistoryFiles_Incremental).Replace("[DBType]", projectConfig.DBType),
                    ScriptFilesStateType.RepeatableChanged => FileSystemPathUtils.ParsePathVaribles(IntegrationTestsConsts.DeliveryArtifactFolderPath_ChangedHistoryFiles_Repeatable).Replace("[DBType]", projectConfig.DBType),
                    ScriptFilesStateType.WithDevDummyDataFiles => FileSystemPathUtils.ParsePathVaribles(IntegrationTestsConsts.DeliveryArtifactFolderPath_WithDevDummyDataFiles).Replace("[DBType]", projectConfig.DBType),
                    ScriptFilesStateType.NoScriptFiles => FileSystemPathUtils.ParsePathVaribles(IntegrationTestsConsts.DeliveryArtifactFolderPath_NoScriptFiles).Replace("[DBType]", projectConfig.DBType),
                    _ => throw new Exception($"Invalid ScriptFilesStateType: '{scriptFilesStateType}'"),
                };
            }
        }
        public ITestContext Arrange(TestArgs testArgs, bool devEnvironment, DBBackupFileType dbBackupFileType, ScriptFilesStateType scriptFilesStateType)
        {
            ITestContext testContext = new ProcessTestContext(testArgs as ProjectConfigTestArgs, dbBackupFileType, scriptFilesStateType);

            testContext.ProjectConfig.DevEnvironment = devEnvironment;

            ProjectConfigItem projectConfig = testContext.ProjectConfig;

            _projectConfigsFactory.SetFoldersPathByDBType(ref projectConfig, testContext.ScriptFilesStateType);

            _projectConfigsStorageHelper.PrepareTestProject(testContext.ProjectConfig);

            if (testContext.DBBackupFileType != DBBackupFileType.None)
            {
                _dbHandler.RestoreDB(testContext.ProjectConfig.DBConnectionInfo, dbBackupFileType);
                testContext.NumOfConnectionsBefore = _dbHandler.GetNumOfOpenConnection(testContext.ProjectConfig.DBConnectionInfo);
            }


            _foldersUtils.RemoveArtifactTempFolder(testContext.ProjectConfig);

            return(testContext);
        }
Example #3
0
        public virtual ProjectConfigItem SetFoldersPathByDBType(ref ProjectConfigItem projectConfig, ScriptFilesStateType scriptFilesStateType)
        {
            SetScriptsFoldersPath(ref projectConfig, scriptFilesStateType);

            projectConfig.DeployArtifactFolderPath = projectConfig.DeployArtifactFolderPath.Replace("[DBType]", projectConfig.DBType);

            return(projectConfig);
        }
Example #4
0
 public ProcessTestContext(ProjectConfigTestArgs projectConfigTestArgs, DBBackupFileType dbBackupFileType, ScriptFilesStateType scriptFilesStateType)
     : this(projectConfigTestArgs)
 {
     DBBackupFileType     = dbBackupFileType;
     ScriptFilesStateType = scriptFilesStateType;
 }