public void GenerateRanorexProjectTest()
        {
            string                   repoFilePath             = @"C:\Users\duongtd\Desktop\samples\Ranorex\Sample1\NewRepository.rxrep";
            List <IElement>          allElements              = new RanorexRxrepAnalyzer().Analyze(repoFilePath);
            MyLog                    myLog                    = new MyLog();
            ExcelSpecificationParser excelSpecificationParser = new ExcelSpecificationParser();
            List <SpecScreen>        specScreens              = excelSpecificationParser.ParseWithRootElements(
                //@"C:\Users\duongtd\Desktop\samples\Ranorex\Sample1\TSDV-Sample-UserCode-Spec.xlsx",
                @"C:\Users\duongtd\Desktop\samples\Ranorex\Sample1\TSDV-Sample-Test.xlsx",
                //@"D:\Research\projects\GUI-Testing-Automation\ProjectGenTemplate\Copy of TSDV-Sample-Mapping-Spec.xlsx",
                allElements, myLog);

            UserActionSpecAnalyzer specAnalyzer = new UserActionSpecAnalyzer();

            specAnalyzer.Expand(specScreens, @"C:\MyApp.exe", myLog);

            ProjectGeneration projectGeneration = new ProjectGeneration();

            projectGeneration.GenerateRanorexProject(allElements,
                                                     specScreens,
                                                     repoFilePath,
                                                     @"C:\Users\duongtd\Desktop\samples\Ranorex\exported",
                                                     @"C:\MyApp.exe",
                                                     myLog);
            System.Diagnostics.Debug.WriteLine(String.Join(",\n", myLog.GetErrorLogs().ToArray()));
        }
Exemple #2
0
        public void RelativePackages_GetsPathResolvedCorrectly()
        {
            var mock  = new Mock <IAssemblyNameProvider>();
            var files = new[]
            {
                "/FullPath/ExamplePackage/Packages/Asset.cs",
            };
            var island = new Assembly("ExamplePackage", "/FullPath/Example/ExamplePackage/ExamplePackage.dll", files, new string[0], new Assembly[0], new string[0], AssemblyFlags.None);

            mock.Setup(x => x.GetAllAssemblies(It.IsAny <Func <string, bool> >())).Returns(new[] { island });
            mock.Setup(x => x.GetAssemblyNameFromScriptPath(It.IsAny <string>())).Returns(string.Empty);
            mock.Setup(x => x.GetAllAssetPaths()).Returns(new[] { "/FullPath/ExamplePackage/Packages/Asset.cs" });
            mock.Setup(x => x.FindForAssetPath("/FullPath/ExamplePackage/Packages/Asset.cs")).Returns(default(UnityEditor.PackageManager.PackageInfo));

            var synchronizer = new ProjectGeneration("/FullPath/Example", mock.Object);
            var syncPaths    = new Dictionary <string, string>();

            synchronizer.Settings = new TestSettings {
                ShouldSync = false, SyncPath = syncPaths
            };

            synchronizer.Sync();

            StringAssert.Contains("\\FullPath\\ExamplePackage\\Packages\\Asset.cs", syncPaths[Path.Combine("/FullPath/Example", $"{island.name}.csproj")]);
        }
        static Dictionary <string, string> SetupProjectGenerationAndReturnCSProjFilesWithContent()
        {
            var projectDirectory = Directory.GetParent(Application.dataPath).FullName;
            var synchronizer     = new ProjectGeneration(projectDirectory);
            var types            = ProjectGeneration.GetAssetPostprocessorTypes();

            synchronizer.GenerateAndWriteSolutionAndProjects(types);

            var files = Directory.GetFiles(projectDirectory);

            return(files.Where(f => Path.GetExtension(f) == ".csproj").ToDictionary(x => x, x => File.ReadAllText(Path.Combine(projectDirectory, x))));
        }
Exemple #4
0
        public void SyncOnlyForSomeAssetTypesOnReimport()
        {
            IEnumerable <string> precompiledAssetImport = new[] { "reimport.dll" };
            IEnumerable <string> asmdefAssetImport      = new[] { "reimport.asmdef" };
            IEnumerable <string> otherAssetImport       = new[] { "reimport.someOther" };

            var projectGeneration = new ProjectGeneration(new FileInfo(s_SolutionFile).DirectoryName);

            Assert.IsTrue(File.Exists(s_SolutionFile));

            var precompiledAssemblySyncIfNeeded = projectGeneration.SyncIfNeeded(Enumerable.Empty <string>().ToArray(), precompiledAssetImport);
            var asmdefSyncIfNeeded    = projectGeneration.SyncIfNeeded(Enumerable.Empty <string>().ToArray(), asmdefAssetImport);
            var someOtherSyncIfNeeded = projectGeneration.SyncIfNeeded(Enumerable.Empty <string>().ToArray(), otherAssetImport);

            Assert.IsTrue(precompiledAssemblySyncIfNeeded);
            Assert.IsTrue(asmdefSyncIfNeeded);
            Assert.IsFalse(someOtherSyncIfNeeded);
        }
Exemple #5
0
        public void FilesNotContributedAnAssemblyWillNotGetAdded()
        {
            var mock  = new Mock <IAssemblyNameProvider>();
            var files = new[]
            {
                "File.cs",
            };
            var island = new Assembly("Assembly2", "/User/Test/Assembly2.dll", files, new string[0], new Assembly[0], new string[0], AssemblyFlags.None);

            mock.Setup(x => x.GetAllAssemblies(It.IsAny <Func <string, bool> >())).Returns(new[] { island });
            mock.Setup(x => x.GetAssemblyNameFromScriptPath(It.IsAny <string>())).Returns(string.Empty);
            mock.Setup(x => x.GetAllAssetPaths()).Returns(new[] { "File/Not/In/Assembly.hlsl" });
            var synchronizer = new ProjectGeneration(Directory.GetParent(Application.dataPath).FullName, mock.Object);

            synchronizer.Sync();
            var csprojContent = File.ReadAllText(synchronizer.ProjectFile(island));

            StringAssert.DoesNotContain("NotExist.hlsl", csprojContent);
        }
Exemple #6
0
        public void FormattedSolution()
        {
            var mock  = new Mock <IAssemblyNameProvider>();
            var files = new[]
            {
                "File.cs",
            };
            var island = new Assembly("Assembly2", "/User/Test/Assembly2.dll", files, new string[0], new Assembly[0], new string[0], AssemblyFlags.None);

            mock.Setup(x => x.GetAllAssemblies(It.IsAny <Func <string, bool> >())).Returns(new[] { island });

            string projectDirectory = Directory.GetParent(Application.dataPath).FullName;
            var    synchronizer     = new ProjectGeneration(projectDirectory, mock.Object);
            var    syncPaths        = new Dictionary <string, string>();

            synchronizer.Settings = new TestSettings {
                ShouldSync = false, SyncPath = syncPaths
            };

            string GetProjectName()
            {
                string[] s = Application.dataPath.Split('/');
                return(s[s.Length - 2]);
            }

            string GetProjectGUID(string projectName)
            {
                return(SolutionGuidGenerator.GuidForProject(GetProjectName() + projectName));
            }

            string GetSolutionGUID(string projectName)
            {
                return(SolutionGuidGenerator.GuidForSolution(projectName, "cs"));
            }

            synchronizer.Sync();

            // solutionguid, solutionname, projectguid
            var solutionExpected = string.Join("\r\n", new[]
            {
                @"",
                @"Microsoft Visual Studio Solution File, Format Version 11.00",
                @"# Visual Studio 2010",
                @"Project(""{{{0}}}"") = ""{2}"", ""{2}.csproj"", ""{{{1}}}""",
                @"EndProject",
                @"Global",
                @"    GlobalSection(SolutionConfigurationPlatforms) = preSolution",
                @"        Debug|Any CPU = Debug|Any CPU",
                @"        Release|Any CPU = Release|Any CPU",
                @"    EndGlobalSection",
                @"    GlobalSection(ProjectConfigurationPlatforms) = postSolution",
                @"        {{{1}}}.Debug|Any CPU.ActiveCfg = Debug|Any CPU",
                @"        {{{1}}}.Debug|Any CPU.Build.0 = Debug|Any CPU",
                @"        {{{1}}}.Release|Any CPU.ActiveCfg = Release|Any CPU",
                @"        {{{1}}}.Release|Any CPU.Build.0 = Release|Any CPU",
                @"    EndGlobalSection",
                @"    GlobalSection(SolutionProperties) = preSolution",
                @"        HideSolutionNode = FALSE",
                @"    EndGlobalSection",
                @"EndGlobal",
                @""
            }).Replace("    ", "\t");

            var solutionTemplate = string.Format(
                solutionExpected,
                GetSolutionGUID(GetProjectName()),
                GetProjectGUID("Assembly2"),
                "Assembly2");

            Assert.AreEqual(solutionTemplate, syncPaths[synchronizer.SolutionFile()]);
        }
 public VSCodeScriptEditor()
 {
     m_Discoverability   = new VSCodeDiscovery();
     m_ProjectGeneration = new ProjectGeneration();
 }