コード例 #1
0
ファイル: MultipleHives.cs プロジェクト: pedrobsaila/runtime
            public SharedTestState()
            {
                DotNetMainHive = DotNet("MainHive")
                                 .AddMicrosoftNETCoreAppFrameworkMockHostPolicy("5.2.0")
                                 .AddMicrosoftNETCoreAppFrameworkMockHostPolicy("6.1.2")
                                 .AddMicrosoftNETCoreAppFrameworkMockHostPolicy("6.1.3")
                                 .AddMicrosoftNETCoreAppFrameworkMockHostPolicy("7.1.2")
                                 .Build();

                DotNetGlobalHive = DotNet("GlobalHive")
                                   .AddMicrosoftNETCoreAppFrameworkMockHostPolicy("5.1.2")
                                   .AddMicrosoftNETCoreAppFrameworkMockHostPolicy("6.1.4")
                                   .AddMicrosoftNETCoreAppFrameworkMockHostPolicy("6.2.0")
                                   .AddMicrosoftNETCoreAppFrameworkMockHostPolicy("7.0.1")
                                   .AddMicrosoftNETCoreAppFrameworkMockHostPolicy("7.1.2")
                                   .Build();

                DotNetCurrentHive = DotNet("CurrentHive")
                                    .AddMicrosoftNETCoreAppFrameworkMockHostPolicy("5.1.0")
                                    .AddMicrosoftNETCoreAppFrameworkMockHostPolicy("7.3.0")
                                    .Build();

                FrameworkReferenceApp = CreateFrameworkReferenceApp();

                _testOnlyProductBehaviorScope = TestOnlyProductBehavior.Enable(DotNetMainHive.GreatestVersionHostFxrFilePath);
            }
コード例 #2
0
 private CommandResult RunTest(Func <RuntimeConfig, RuntimeConfig> runtimeConfig)
 {
     using (TestOnlyProductBehavior.Enable(SharedState.DotNetMainHive.GreatestVersionHostFxrFilePath))
     {
         return(RunTest(
                    SharedState.DotNetMainHive,
                    SharedState.FrameworkReferenceApp,
                    new TestSettings()
                    .WithRuntimeConfigCustomizer(runtimeConfig)
                    .WithEnvironment(Constants.TestOnlyEnvironmentVariables.GloballyRegisteredPath, SharedState.DotNetGlobalHive.BinPath),
                    // Must enable multi-level lookup otherwise multiple hives are not enabled
                    multiLevelLookup: true));
     }
 }
コード例 #3
0
 private CommandResult RunTest(Func <RuntimeConfig, RuntimeConfig> runtimeConfig)
 {
     using (TestOnlyProductBehavior.Enable(SharedState.DotNetMainHive.GreatestVersionHostFxrFilePath))
     {
         return(RunTest(
                    SharedState.DotNetMainHive,
                    SharedState.FrameworkReferenceApp,
                    new TestSettings()
                    .WithRuntimeConfigCustomizer(runtimeConfig)
                    .WithEnvironment(Constants.TestOnlyEnvironmentVariables.GloballyRegisteredPath, SharedState.DotNetGlobalHive.BinPath)
                    .WithEnvironment( // Redirect the default install location to an invalid location so that a machine-wide install is not used
                        Constants.TestOnlyEnvironmentVariables.DefaultInstallPath,
                        System.IO.Path.Combine(SharedState.DotNetMainHive.BinPath, "invalid")),
                    // Must enable multi-level lookup otherwise multiple hives are not enabled
                    multiLevelLookup: true));
     }
 }
コード例 #4
0
        public void EnvironmentVariable_DotnetRootPathExistsButHasNoHost()
        {
            var fixture = sharedTestState.PortableAppFixture
                          .Copy();

            var appExe  = fixture.TestProject.AppExe;
            var projDir = fixture.TestProject.ProjectDirectory;

            using (TestOnlyProductBehavior.Enable(appExe))
            {
                Command.Create(appExe)
                .EnableTracingAndCaptureOutputs()
                .DotNetRoot(projDir)
                .MultilevelLookup(false)
                .EnvironmentVariable(
                    Constants.TestOnlyEnvironmentVariables.GloballyRegisteredPath,
                    sharedTestState.InstallLocation)
                .Execute()
                .Should().Fail()
                .And.HaveUsedDotNetRootInstallLocation(projDir, fixture.CurrentRid)
                // If DOTNET_ROOT points to a folder that exists we assume that there's a dotnet installation in it
                .And.HaveStdErrContaining($"The required library {RuntimeInformationExtensions.GetSharedLibraryFileNameForCurrentPlatform("hostfxr")} could not be found.");
            }
        }
コード例 #5
0
        public void EnvironmentVariable_DotnetRootPathDoesNotExist()
        {
            var fixture = sharedTestState.PortableAppFixture
                          .Copy();

            var appExe = fixture.TestProject.AppExe;

            using (TestOnlyProductBehavior.Enable(appExe))
            {
                Command.Create(appExe)
                .EnableTracingAndCaptureOutputs()
                .DotNetRoot("non_existent_path")
                .MultilevelLookup(false)
                .EnvironmentVariable(
                    Constants.TestOnlyEnvironmentVariables.GloballyRegisteredPath,
                    sharedTestState.InstallLocation)
                .Execute()
                .Should().Pass()
                .And.HaveStdErrContaining("Did not find [DOTNET_ROOT] directory [non_existent_path]")
                // If DOTNET_ROOT points to a folder that does not exist, we fall back to the global install path.
                .And.HaveUsedGlobalInstallLocation(sharedTestState.InstallLocation)
                .And.HaveStdOutContaining("Hello World");
            }
        }