Пример #1
0
        public void Run_apphost_behind_transitive_symlinks(string firstSymlinkRelativePath, string secondSymlinkRelativePath)
        {
            // Creating symbolic links requires administrative privilege on Windows, so skip test.
            if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
            {
                return;
            }

            var fixture = sharedTestState.StandaloneAppFixture_Published
                          .Copy();

            var appExe  = fixture.TestProject.AppExe;
            var testDir = Directory.GetParent(fixture.TestProject.Location).ToString();

            // second symlink -> apphost
            string symlink2Path = Path.Combine(testDir, secondSymlinkRelativePath);

            Directory.CreateDirectory(Path.GetDirectoryName(symlink2Path));
            using var symlink2 = new SymLink(symlink2Path, appExe);

            // first symlink -> second symlink
            string symlink1Path = Path.Combine(testDir, firstSymlinkRelativePath);

            Directory.CreateDirectory(Path.GetDirectoryName(symlink1Path));
            using var symlink1 = new SymLink(symlink1Path, symlink2Path);

            Command.Create(symlink1.SrcPath)
            .CaptureStdErr()
            .CaptureStdOut()
            .Execute()
            .Should().Pass()
            .And.HaveStdOutContaining("Hello World");
        }
Пример #2
0
        public void Run_framework_dependent_app_behind_symlink(/*string symlinkRelativePath*/)
        {
            // Creating symbolic links requires administrative privilege on Windows, so skip test.
            if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
            {
                return;
            }

            var symlinkRelativePath = string.Empty;

            var fixture = sharedTestState.FrameworkDependentAppFixture_Published
                          .Copy();

            var appExe      = fixture.TestProject.AppExe;
            var builtDotnet = fixture.BuiltDotnet.BinPath;
            var testDir     = Directory.GetParent(fixture.TestProject.Location).ToString();

            Directory.CreateDirectory(Path.Combine(testDir, Path.GetDirectoryName(symlinkRelativePath)));

            using var symlink = new SymLink(Path.Combine(testDir, symlinkRelativePath), appExe);
            Command.Create(symlink.SrcPath)
            .CaptureStdErr()
            .CaptureStdOut()
            .EnvironmentVariable("DOTNET_ROOT", builtDotnet)
            .EnvironmentVariable("DOTNET_ROOT(x86)", builtDotnet)
            .Execute()
            .Should().Pass()
            .And.HaveStdOutContaining("Hello World");
        }
Пример #3
0
        public void Put_app_directory_behind_symlink_and_use_dotnet_run()
        {
            // Creating symbolic links requires administrative privilege on Windows, so skip test.
            if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
            {
                return;
            }

            var fixture = sharedTestState.StandaloneAppFixture_Published
                          .Copy();

            var dotnet        = fixture.SdkDotnet;
            var binDir        = fixture.TestProject.OutputDirectory;
            var binDirNewPath = Path.Combine(Directory.GetParent(fixture.TestProject.Location).ToString(), "PutTheBinDirSomewhereElse");

            Directory.Move(binDir, binDirNewPath);

            using var symlink = new SymLink(binDir, binDirNewPath);
            dotnet.Exec("run")
            .WorkingDirectory(fixture.TestProject.Location)
            .CaptureStdErr()
            .CaptureStdOut()
            .Execute()
            .Should().Pass()
            .And.HaveStdOutContaining("Hello World");
        }
Пример #4
0
        public void Run_apphost_behind_transitive_symlinks(string firstSymlinkRelativePath, string secondSymlinkRelativePath)
        {
            var fixture = sharedTestState.StandaloneAppFixture_Published
                          .Copy();

            var appExe  = fixture.TestProject.AppExe;
            var testDir = Directory.GetParent(fixture.TestProject.Location).ToString();

            // second symlink -> apphost
            string symlink2Path = Path.Combine(testDir, secondSymlinkRelativePath);

            Directory.CreateDirectory(Path.GetDirectoryName(symlink2Path));
            using var symlink2 = new SymLink(symlink2Path, appExe);

            // first symlink -> second symlink
            string symlink1Path = Path.Combine(testDir, firstSymlinkRelativePath);

            Directory.CreateDirectory(Path.GetDirectoryName(symlink1Path));
            using var symlink1 = new SymLink(symlink1Path, symlink2Path);

            Command.Create(symlink1.SrcPath)
            .CaptureStdErr()
            .CaptureStdOut()
            .Execute()
            .Should().Pass()
            .And.HaveStdOutContaining("Hello World");
        }
Пример #5
0
        public void Put_satellite_assembly_behind_symlink()
        {
            var fixture = sharedTestState.StandaloneAppFixture_Localized
                          .Copy();

            var appExe        = fixture.TestProject.AppExe;
            var binDir        = fixture.TestProject.OutputDirectory;
            var satellitesDir = Path.Combine(Directory.GetParent(fixture.TestProject.Location).ToString(), "PutSatellitesSomewhereElse");

            Directory.CreateDirectory(satellitesDir);

            var firstSatelliteDir    = Directory.GetDirectories(binDir).Single(dir => dir.Contains("kn-IN"));
            var firstSatelliteNewDir = Path.Combine(satellitesDir, "kn-IN");

            Directory.Move(firstSatelliteDir, firstSatelliteNewDir);
            using var symlink1 = new SymLink(firstSatelliteDir, firstSatelliteNewDir);

            var secondSatelliteDir    = Directory.GetDirectories(binDir).Single(dir => dir.Contains("ta-IN"));
            var secondSatelliteNewDir = Path.Combine(satellitesDir, "ta-IN");

            Directory.Move(secondSatelliteDir, secondSatelliteNewDir);
            using var symlink2 = new SymLink(secondSatelliteDir, secondSatelliteNewDir);

            Command.Create(appExe)
            .CaptureStdErr()
            .CaptureStdOut()
            .Execute()
            .Should().Pass()
            .And.HaveStdOutContaining("ನಮಸ್ಕಾರ! வணக்கம்! Hello!");
        }
        private void MenuItemDisabler(bool isShortcut, bool isExeDllFile)
        {
            if (isShortcut)
            {
                if (BlockFirewall != null)
                {
                    BlockFirewall.Dispose();
                }
                if (Attributes != null)
                {
                    Attributes.Dispose();
                }
                if (SymLink != null)
                {
                    SymLink.Dispose();
                }
                if (TakeOwnership != null)
                {
                    TakeOwnership.Dispose();
                }
            }
            if (isExeDllFile)
            {
                if (OpenNotepad != null)
                {
                    OpenNotepad.Dispose();
                }
            }
            if (!isExeDllFile)
            {
                if (BlockFirewall != null)
                {
                    BlockFirewall.Dispose();
                }
            }
            bool AllDisabled = true;

            foreach (ToolStripMenuItem item in MenuToolsMenu.DropDownItems)
            {
                if (item != null)
                {
                    AllDisabled = false;
                }
            }
            if (AllDisabled)
            {
                Menu.Dispose();
            }
        }
Пример #7
0
        public void Put_dotnet_behind_symlink()
        {
            var fixture = sharedTestState.StandaloneAppFixture_Published
                          .Copy();

            var appDll        = fixture.TestProject.AppDll;
            var dotnetExe     = fixture.BuiltDotnet.DotnetExecutablePath;
            var testDir       = Directory.GetParent(fixture.TestProject.Location).ToString();
            var dotnetSymlink = Path.Combine(testDir, "dotnet");

            using var symlink = new SymLink(dotnetSymlink, dotnetExe);
            Command.Create(symlink.SrcPath, fixture.TestProject.AppDll)
            .CaptureStdErr()
            .CaptureStdOut()
            .Execute()
            .Should().Pass()
            .And.HaveStdOutContaining("Hello World");
        }
Пример #8
0
        public void Put_app_directory_behind_symlink_and_use_dotnet()
        {
            var fixture = sharedTestState.StandaloneAppFixture_Published
                          .Copy();

            var dotnet        = fixture.BuiltDotnet;
            var binDir        = fixture.TestProject.OutputDirectory;
            var binDirNewPath = Path.Combine(Directory.GetParent(fixture.TestProject.Location).ToString(), "PutTheBinDirSomewhereElse");

            Directory.Move(binDir, binDirNewPath);

            using var symlink = new SymLink(binDir, binDirNewPath);
            dotnet.Exec(fixture.TestProject.AppDll)
            .CaptureStdErr()
            .CaptureStdOut()
            .Execute()
            .Should().Pass()
            .And.HaveStdOutContaining("Hello World");
        }
Пример #9
0
        public void Run_framework_dependent_app_with_runtime_behind_symlink()
        {
            var fixture = sharedTestState.FrameworkDependentAppFixture_Published
                          .Copy();

            var appExe        = fixture.TestProject.AppExe;
            var testDir       = Directory.GetParent(fixture.TestProject.Location).ToString();
            var dotnetSymlink = Path.Combine(testDir, "dotnet");
            var dotnetDir     = fixture.BuiltDotnet.BinPath;

            using var symlink = new SymLink(dotnetSymlink, dotnetDir);
            Command.Create(appExe)
            .EnvironmentVariable("DOTNET_ROOT", symlink.SrcPath)
            .CaptureStdErr()
            .CaptureStdOut()
            .Execute()
            .Should().Pass()
            .And.HaveStdOutContaining("Hello World");
        }
Пример #10
0
        public void Put_satellite_assembly_behind_symlink()
        {
            // Creating symbolic links requires administrative privilege on Windows, so skip test.
            // If enabled, this tests will need to set the console code page to output unicode characters:
            // Command.Create("chcp 65001").Execute();
            if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
            {
                return;
            }

            var fixture = sharedTestState.StandaloneAppFixture_Localized
                          .Copy();

            var appExe        = fixture.TestProject.AppExe;
            var binDir        = fixture.TestProject.OutputDirectory;
            var satellitesDir = Path.Combine(Directory.GetParent(fixture.TestProject.Location).ToString(), "PutSatellitesSomewhereElse");

            Directory.CreateDirectory(satellitesDir);

            var firstSatelliteDir    = Directory.GetDirectories(binDir).Single(dir => dir.Contains("kn-IN"));
            var firstSatelliteNewDir = Path.Combine(satellitesDir, "kn-IN");

            Directory.Move(firstSatelliteDir, firstSatelliteNewDir);
            using var symlink1 = new SymLink(firstSatelliteDir, firstSatelliteNewDir);

            var secondSatelliteDir    = Directory.GetDirectories(binDir).Single(dir => dir.Contains("ta-IN"));
            var secondSatelliteNewDir = Path.Combine(satellitesDir, "ta-IN");

            Directory.Move(secondSatelliteDir, secondSatelliteNewDir);
            using var symlink2 = new SymLink(secondSatelliteDir, secondSatelliteNewDir);

            Command.Create(appExe)
            .CaptureStdErr()
            .CaptureStdOut()
            .Execute()
            .Should().Pass()
            .And.HaveStdOutContaining("ನಮಸ್ಕಾರ! வணக்கம்! Hello!");
        }
Пример #11
0
        public void Put_dotnet_behind_symlink()
        {
            // Creating symbolic links requires administrative privilege on Windows, so skip test.
            if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
            {
                return;
            }

            var fixture = sharedTestState.StandaloneAppFixture_Published
                          .Copy();

            var appDll        = fixture.TestProject.AppDll;
            var dotnetExe     = fixture.BuiltDotnet.DotnetExecutablePath;
            var testDir       = Directory.GetParent(fixture.TestProject.Location).ToString();
            var dotnetSymlink = Path.Combine(testDir, "dotnet");

            using var symlink = new SymLink(dotnetSymlink, dotnetExe);
            Command.Create(symlink.SrcPath, fixture.TestProject.AppDll)
            .CaptureStdErr()
            .CaptureStdOut()
            .Execute()
            .Should().Pass()
            .And.HaveStdOutContaining("Hello World");
        }