Пример #1
0
        private GlobalGeneratedFileNames Create_RequiredFiles_InsideSolutionFolder(string moduleId, string suiteName, List <string> scenarioMethodNames, TestCaseScenario scenarioConfig)
        {
            //Step 3: create top level files: MasterRunner_AutoGenTests.cs, MasterRunner_UserTests.cs, ModuleXYZ_TestSuite.xml,TestConfig.cs

            GlobalGeneratedFileNames fileNameListing = new GlobalGeneratedFileNames();

            MasterRunnerAutoGenCSharpFileGenerator csFile_autoGen = new MasterRunnerAutoGenCSharpFileGenerator(moduleId, suiteName);

            csFile_autoGen.TemplateDataObject.ComputedList_For_ScenarioMethod = scenarioMethodNames;
            fileNameListing.CsFile_AutoGenTest = csFile_autoGen.GenerateFile(this._SolutionContentFolderFullPath);

            MasterRunnerUserCSharpFileGenerator csFile_user = new MasterRunnerUserCSharpFileGenerator(moduleId, suiteName);

            fileNameListing.CsFile_UserTest = csFile_user.GenerateFile(this._SolutionContentFolderFullPath);

            string fileNameModifier = this.SolutionGenConfig.IsGeneratedDistinctSuiteXmlConfig ? ("_" + this._DateTimeStamp) : string.Empty;
            TestSuiteXmlFileGenerator testSuiteXmlFile = new TestSuiteXmlFileGenerator(moduleId, fileNameModifier, Get_TestSuiteConfigFile_Object(scenarioMethodNames, scenarioConfig));

            fileNameListing.TestSuiteXmlFile = testSuiteXmlFile.GenerateFile(this._SolutionContentFolderFullPath);

            TestSuiteAppConfigGenerator testSuiteAppConfig = new TestSuiteAppConfigGenerator(moduleId, fileNameModifier, Get_TestSuiteAppConfig(scenarioConfig));

            fileNameListing.ConfigFile_AppSettingConfigFile = testSuiteAppConfig.GenerateFile(this._SolutionContentFolderFullPath);

            TestConfigCSharpFileGenerator csFile_TestConfigFile = new Core.CodeSolutionBuilder.TestConfigCSharpFileGenerator(moduleId);

            fileNameListing.CsFile_TestConfigFile = csFile_TestConfigFile.GenerateFile(this._SolutionContentFolderFullPath);

            return(fileNameListing);
        }
Пример #2
0
        protected GlobalGeneratedFileNames Generate_Core(TestCaseScenario scenarioConfig, SolutionGenerationConfig solutionConfig)
        {
            this.SolutionGenConfig = solutionConfig;

            string suiteName = scenarioConfig.ModuleConfig.ModuleId + "_TestSuite";

            //Step 1: Create Solution Folder
            this.Create_SolutionFolder_WithDateTimeStamp(suiteName);

            string assemblyName = scenarioConfig.ModuleConfig.AutoGeneratedProjectNamespace + (this.SolutionGenConfig.IsGeneratedDistinctSuiteXmlConfig ? ("_" + this._DateTimeStamp) : string.Empty);

            scenarioConfig.ModuleConfig.AssemblyName = assemblyName;

            //Step 2: create necessary folders : create top level folders : AutoGenTests & UserTests
            this.Create_RequiredFolders_InsideSolutionFolder();

            List <string> scenarioMethodNames = new List <string>();

            scenarioConfig.Scenarios.ForEach((s) =>
            {
                scenarioMethodNames.Add(s.Name);
            });

            //Step 3: create top level files: MasterRunner_AutoGenTests.cs, MasterRunner_UserTests.cs, ModuleXYZ_TestSuite.xml,TestConfig.cs
            GlobalGeneratedFileNames globalGeneratedFileNames = this.Create_RequiredFiles_InsideSolutionFolder(scenarioConfig.ModuleConfig.ModuleId, suiteName, scenarioMethodNames, scenarioConfig);

            //Step 4: create files inside AutoGenTests folder
            //TC._.cs
            this.Create_TestCaseMainFile_InsideAutoGenTests(scenarioConfig.ModuleConfig);
            //TC.Scenario.cs
            List <GeneratorScenarioFileObject> scenarioFileList = Create_All_TestCaseScenarioFile_InsideAutoGenTests(scenarioConfig); //TODO: substitue null with object

            //Step 5: copy old UserTests contents
            //TODO: based on time constraint

            //Step 6: Create only one project for now :  project 1
            GeneratorProjectXmlFile csprojXmlObj = this.Create_ProjectFile(
                scenarioConfig.ModuleConfig.ModuleId,
                scenarioFileList,
                globalGeneratedFileNames.TestSuiteXmlFile,
                assemblyName
                );

            //Step 7: Create Assembly file name under properties using GeneratorProjectXmlFile
            Create_AssemblyInfoCsFile(csprojXmlObj);

            //Step 8: Create Solution File (yipee!!!)
            Create_SolutionFile(new List <GeneratorProjectXmlFile>()
            {
                csprojXmlObj
            });

            return(globalGeneratedFileNames);
        }
Пример #3
0
        public void Generate(TestCaseScenario scenarioConfig, SolutionGenerationConfig solutionConfig, StreamWriter sWrite = null)
        {
            if (!Directory.Exists(solutionConfig.SolutionTargetPath))
            {
                Directory.CreateDirectory(solutionConfig.SolutionTargetPath);
            }

            GlobalGeneratedFileNames fileNameListing = Generate_Core(scenarioConfig, solutionConfig);

            sWrite.WriteLine("Code generation started");

            if (this.SolutionGenConfig.IsCompileAndGenerateLibrary)
            {
                this._SolutionCompiledCodeFolderFullPath = Path.Combine(this.SolutionGenConfig.SolutionTargetPath, CONST_FOLDER_COMPILED_CODE_CONTAINER);
                //string targetCompiledFolderPath = Path.Combine(this.SolutionGenConfig.SolutionTargetPath, "CompiledCode");

                string dllFileNameWithFullPath;
                bool   isCOmpileSuccess = this.BuildRunLibrary(sWrite, this._SolutionCompiledCodeFolderFullPath, out dllFileNameWithFullPath);

                if (isCOmpileSuccess)
                {
                    //copy TestSuiteXmlFile  To TargetCompiledPath
                    string xmlFileNameWithFullPath = this.CopyFile_ToTargetCompiledPath(fileNameListing.TestSuiteXmlFile, this._SolutionContentFolderFullPath, this._SolutionCompiledCodeFolderFullPath);

                    //Copy AppConfigFile To TargetCompiledPath
                    string appSettingFilePath = this.CopyFile_ToTargetCompiledPath(fileNameListing.ConfigFile_AppSettingConfigFile, this._SolutionContentFolderFullPath, this._SolutionCompiledCodeFolderFullPath);

                    if (this.SolutionGenConfig.IsAutoDeploy)
                    {
                        string dllfileNameWithoutExtension = Path.GetFileNameWithoutExtension(dllFileNameWithFullPath);
                        string src_dllLocationPath         = Path.GetDirectoryName(dllFileNameWithFullPath);

                        string dllFileName = dllfileNameWithoutExtension + ".dll";
                        string pdbFileName = dllfileNameWithoutExtension + ".pdb";

                        string xmlFileName        = Path.GetFileName(xmlFileNameWithFullPath);
                        string appSettingFileName = Path.GetFileName(appSettingFilePath);

                        //Copy dll and pdb file
                        if (File.Exists(Path.Combine(src_dllLocationPath, dllFileName)))
                        {
                            File.Copy(Path.Combine(src_dllLocationPath, dllFileName), Path.Combine(this.SolutionGenConfig.AutoDeployPath, dllFileName), true);
                        }
                        if (File.Exists(Path.Combine(src_dllLocationPath, pdbFileName)))
                        {
                            File.Copy(Path.Combine(src_dllLocationPath, pdbFileName), Path.Combine(this.SolutionGenConfig.AutoDeployPath, pdbFileName), true);
                        }

                        //copy xml file
                        if (File.Exists(xmlFileNameWithFullPath))
                        {
                            File.Copy(xmlFileNameWithFullPath, Path.Combine(this.SolutionGenConfig.AutoDeployPath, xmlFileName), true);
                        }

                        //copy app.Config file
                        if (File.Exists(appSettingFilePath))
                        {
                            File.Copy(appSettingFilePath, Path.Combine(this.SolutionGenConfig.AutoDeployPath, appSettingFileName), true);
                        }
                    }
                }
            }

            sWrite.WriteLine("Code generation completed");
        }