public void GetTsconfigBuildFilesForSingleItem()
        {
            string      projectItemFullName = Path.GetFullPath(@"../../artifacts/tsconfig/multiple/a/file1.ts");
            string      projectFullName     = Path.GetFullPath(@"../../artifacts/tsconfig/multiple/tsconfigTest.csproj");
            Project     project             = TsconfigLocationsTest.FindProject(projectFullName, solution);
            ProjectItem projectItem         = TsconfigLocationsTest.FindProjectItemInProject(projectItemFullName, project);

            MockUIHierarchyItem mockSolutionHierarchyItem = new MockUIHierarchyItem()
            {
                Object = projectItem
            };

            UIHierarchyItem[] selectedItems = new UIHierarchyItem[] { mockSolutionHierarchyItem };

            List <string> results = BuildFileLocations.GetBuildFilesToLint(isBuildingSolution: false,
                                                                           selectedItems: selectedItems, useTsConfig: true).ToList();

            // Again we are going to build the project the item is in so should lint for all tsconfigs in the project
            Assert.AreEqual(3, results.Count);

            string expected1 = Path.GetFullPath(@"../../artifacts/tsconfig/multiple/tsconfig.json");
            string expected2 = Path.GetFullPath(@"../../artifacts/tsconfig/multiple/a/tsconfig.json");
            string expected3 = Path.GetFullPath(@"../../artifacts/tsconfig/multiple/b/tsconfig.json");

            Assert.IsTrue(results.Contains(expected1));
            Assert.IsTrue(results.Contains(expected2));
            Assert.IsTrue(results.Contains(expected3));
        }
Ejemplo n.º 2
0
        public void GetLintFilesForProject()
        {
            string              projectFullName           = Path.GetFullPath(@"../../artifacts/tsconfig/none/tsconfigEmptyTest.csproj");
            Project             project                   = TsconfigLocationsTest.FindProject(projectFullName, solution);
            MockUIHierarchyItem mockSolutionHierarchyItem = new MockUIHierarchyItem()
            {
                Object = project
            };

            UIHierarchyItem[] selectedItems = new UIHierarchyItem[] { mockSolutionHierarchyItem };

            string[] results = LintFileLocations.FindPathsFromSelectedItems(selectedItems, out Dictionary <string, string> fileToProjectMap);

            Assert.AreEqual(1, results.Length);
            string expected1 = Path.GetFullPath(@"../../artifacts/tsconfig/none/b/file5.ts");

            Assert.IsTrue(results.Contains(expected1));
        }
        public void GetBuildFilesForProject()
        {
            string              projectFullName           = Path.GetFullPath(@"../../artifacts/tsconfig/none/tsconfigEmptyTest.csproj");
            Project             project                   = TsconfigLocationsTest.FindProject(projectFullName, solution);
            MockUIHierarchyItem mockSolutionHierarchyItem = new MockUIHierarchyItem()
            {
                Object = project
            };

            UIHierarchyItem[] selectedItems = new UIHierarchyItem[] { mockSolutionHierarchyItem };

            List <string> results = BuildFileLocations.GetBuildFilesToLint(isBuildingSolution: false,
                                                                           selectedItems: selectedItems, useTsConfig: false).ToList();

            Assert.AreEqual(1, results.Count);
            string expected1 = Path.GetFullPath(@"../../artifacts/tsconfig/none/b/file5.ts");

            Assert.IsTrue(results.Contains(expected1));
        }
        public void GetLintFilesForSingleItem()
        {
            string      projectItemFullName = Path.GetFullPath(@"../../artifacts/tsconfig/multiple/a/file1.ts");
            string      projectFullName     = Path.GetFullPath(@"../../artifacts/tsconfig/multiple/tsconfigTest.csproj");
            Project     project             = TsconfigLocationsTest.FindProject(projectFullName, solution);
            ProjectItem projectItem         = TsconfigLocationsTest.FindProjectItemInProject(projectItemFullName, project);

            MockUIHierarchyItem mockSolutionHierarchyItem = new MockUIHierarchyItem()
            {
                Object = projectItem
            };

            UIHierarchyItem[] selectedItems = new UIHierarchyItem[] { mockSolutionHierarchyItem };

            List <string> results = LintFileLocations.FindPathsFromSelectedItems(selectedItems).ToList();

            Assert.AreEqual(1, results.Count);
            Assert.AreEqual(projectItemFullName, results[0]);
            //string expected1 = Path.GetFullPath(@"../../artifacts/tsconfig/none/b/file5.ts");
            //Assert.IsTrue(results.Contains(expected1));
        }
        public void GetBuildFilesForSingleItem()
        {
            string      projectItemFullName = Path.GetFullPath(@"../../artifacts/tsconfig/multiple/a/file1.ts");
            string      projectFullName     = Path.GetFullPath(@"../../artifacts/tsconfig/multiple/tsconfigTest.csproj");
            Project     project             = TsconfigLocationsTest.FindProject(projectFullName, solution);
            ProjectItem projectItem         = TsconfigLocationsTest.FindProjectItemInProject(projectItemFullName, project);

            MockUIHierarchyItem mockSolutionHierarchyItem = new MockUIHierarchyItem()
            {
                Object = projectItem
            };

            UIHierarchyItem[] selectedItems = new UIHierarchyItem[] { mockSolutionHierarchyItem };

            List <string> results = BuildFileLocations.GetBuildFilesToLint(isBuildingSolution: false,
                                                                           selectedItems: selectedItems, useTsConfig: false).ToList();

            // We're going to build the project that the individual file is in (tsconfigTest) and so need to lint
            // all the files in said project before the build.  Note NOT using tsconfig.json (useTsConfig: false above).
            Assert.AreEqual(8, results.Count);

            string expected1 = Path.GetFullPath(@"../../artifacts/tsconfig/multiple/react-dom.d.ts");
            string expected2 = Path.GetFullPath(@"../../artifacts/tsconfig/multiple/react.d.ts");
            string expected3 = Path.GetFullPath(@"../../artifacts/tsconfig/multiple/test.ts");
            string expected4 = Path.GetFullPath(@"../../artifacts/tsconfig/multiple/a/file1.ts");
            string expected5 = Path.GetFullPath(@"../../artifacts/tsconfig/multiple/a/c/file4.ts");
            string expected6 = Path.GetFullPath(@"../../artifacts/tsconfig/multiple/b/file3.ts");
            string expected7 = Path.GetFullPath(@"../../artifacts/tsconfig/multiple/a/c/file6.tsx");
            string expected8 = Path.GetFullPath(@"../../artifacts/tsconfig/file9.ts"); // Linked file

            Assert.IsTrue(results.Contains(expected1));
            Assert.IsTrue(results.Contains(expected2));
            Assert.IsTrue(results.Contains(expected3));
            Assert.IsTrue(results.Contains(expected4));
            Assert.IsTrue(results.Contains(expected5));
            Assert.IsTrue(results.Contains(expected6));
            Assert.IsTrue(results.Contains(expected7));
            Assert.IsTrue(results.Contains(expected8));
        }