Example #1
0
        public void TestGetRelativeFilePath()
        {
            foreach (var testCase in Triples(
                         @"C:\a\b", @"C:\file.exe", @"..\..\file.exe",
                         @"C:\a\b", @"C:\a\file.exe", @"..\file.exe",
                         @"C:\a\b\c", @"C:\a\file.exe", @"..\..\file.exe",
                         @"C:\a\b", @"C:\A\B\file.exe", @"file.exe",
                         @"C:\a\b", @"C:\a\B\C\file.exe", @"C\file.exe",
                         @"C:\a\b", @"D:\a\b\file.exe", @"D:\a\b\file.exe",
                         @"C:\a\b", @"C:\d\e\file.exe", @"..\..\d\e\file.exe",

                         @"\\root\share\path", @"\\Root\Share\file.exe", @"..\file.exe",
                         @"\\root\share\path", @"\\Root\Share\Path\file.exe", @"file.exe",
                         @"\\root\share\path", @"\\Root\share\Path\subpath\file.exe", @"subpath\file.exe",
                         @"\\root\share\path\subpath", @"\\Root\share\Path\othersubpath\file.exe", @"..\othersubpath\file.exe",
                         @"\\root\share\path", @"\\root\othershare\path\file.exe", @"..\..\othershare\path\file.exe",
                         @"\\root\share\path", @"\\root\share\otherpath\file.exe", @"..\otherpath\file.exe",
                         @"\\root\share\", @"\\otherroot\share\file.exe", @"\\otherroot\share\file.exe",

                         @"ftp://[email protected]/share/path", @"ftp://[email protected]/file.exe", @"../../file.exe",
                         @"ftp://[email protected]/share/path", @"ftp://[email protected]/Share/file.exe", @"../../Share/file.exe",
                         @"ftp://[email protected]/share/path", @"ftp://[email protected]/share/path/subpath/file.exe", @"subpath/file.exe",
                         @"ftp://[email protected]/share/path", @"ftp://[email protected]/share/Path/subpath/file.exe", @"../Path/subpath/file.exe",
                         @"ftp://[email protected]/share/path/subpath", @"ftp://[email protected]/share/path/othersubpath/file.exe", @"../othersubpath/file.exe",
                         @"ftp://[email protected]/share/path/subpath", @"ftp://[email protected]/share/Path/othersubpath/file.exe", @"../../Path/othersubpath/file.exe",
                         @"ftp://[email protected]/path", @"ftp://[email protected]/otherpath/file.exe", @"../otherpath/file.exe",

                         @"C:\a\b", "C:\\a\\b\\", @"",
                         // This is the expected behavior for GetRelativeFilePath
                         // because the 'b' in the second part is assumed to be a file
                         // and hence may be different to the directory 'b' in the first
                         // part.
                         // GetRelativeDirectoryPath returns an empty string, because it
                         // assumes that both paths are directories.
                         "C:\\a\\b\\", @"C:\a\b", @"..\b",

                         // Ensure end-separators are retained when the target is a
                         // directory rather than a file.
                         "C:\\a\\", "C:\\a\\b\\", "b\\",
                         "C:\\a", "C:\\a\\b\\", "b\\"
                         ))
            {
                var expected = testCase.Item3;
                var actual   = CommonUtils.GetRelativeFilePath(testCase.Item1, testCase.Item2);

                Assert.AreEqual(expected, actual, string.Format("From {0} to {1}", testCase.Item1, testCase.Item2));
            }
        }
Example #2
0
        public void TestPublishVirtualEnvironment(VisualStudioApp app)
        {
            var project = app.OpenProject(app.CopyProjectForTest(@"TestData\VirtualEnv.sln"));
            var dir     = TestData.GetTempPath();

            project.Properties.Item("PublishUrl").Value = dir;
            app.OnDispose(() => project.Properties.Item("PublishUrl").Value = "");

            app.OpenSolutionExplorer().SelectProject(project);
            var files = PublishAndWaitForFiles(app, "Build.PublishSelection", dir);

            Assert.IsNotNull(files, "Timed out waiting for files to publish");
            AssertUtil.ContainsAtLeast(
                files.Select(f => CommonUtils.GetRelativeFilePath(dir, f).ToLowerInvariant()),
                "env\\include\\pyconfig.h",
                "env\\lib\\site.py",
                "env\\scripts\\python.exe",
                "program.py"
                );

            Directory.Delete(dir, true);
        }