Beispiel #1
0
        public void SholdUseEnvironmentVariableToGetDefaultLocation()
        {
            var environment = EnvironmentMockBuilder.Create()
                              .AddVariable("NUGET_PACKAGES", PackagesPath)
                              .Build();

            var result = PackageCompilationAssemblyResolver.GetDefaultPackageDirectory(Platform.Unknown, environment);

            result.Should().Be(PackagesPath);
        }
Beispiel #2
0
        public void SholdUseNugetUnderHomeOnNonWindows()
        {
            var environment = EnvironmentMockBuilder.Create()
                              .AddVariable("HOME", "User Home")
                              .Build();

            var result = PackageCompilationAssemblyResolver.GetDefaultPackageDirectory(Platform.Linux, environment);

            result.Should().Be(Path.Combine("User Home", ".nuget", "packages"));
        }
        public void ReturnsProgramFilesAsDefaultLocationOnWin32()
        {
            var environment = EnvironmentMockBuilder.Create()
                              .AddVariable("ProgramFiles", "Program Files")
                              .Build();

            var result = ReferenceAssemblyPathResolver.GetDefaultReferenceAssembliesPath(FileSystemMockBuilder.Empty, Platform.Windows, environment);

            result.Should().Be(Path.Combine("Program Files", "Reference Assemblies", "Microsoft", "Framework"));
        }
        public void UsesEnvironmentVariableForDefaultPath()
        {
            var environment = EnvironmentMockBuilder.Create()
                              .AddVariable("DOTNET_REFERENCE_ASSEMBLIES_PATH", ReferencePath)
                              .Build();

            var result = ReferenceAssemblyPathResolver.GetDefaultReferenceAssembliesPath(FileSystemMockBuilder.Empty, Platform.Windows, environment);

            result.Should().Be(ReferencePath);
        }
Beispiel #5
0
        public void ShouldUseNugetUnderUserProfileOnWindows()
        {
            var environment = EnvironmentMockBuilder.Create()
                              .AddVariable("USERPROFILE", "User Profile")
                              .Build();

            var result = PackageCompilationAssemblyResolver.GetDefaultProbeDirectories(Platform.Windows, environment);

            result.Should().Contain(Path.Combine("User Profile", ".nuget", "packages"));
        }
Beispiel #6
0
        public void ShouldUseEnvironmentVariableToGetDefaultLocation()
        {
            var environment = EnvironmentMockBuilder.Create()
                              .AddVariable("NUGET_PACKAGES", PackagesPath)
                              .AddAppContextData("PROBING_DIRECTORIES", string.Empty)
                              .Build();

            var result = PackageCompilationAssemblyResolver.GetDefaultProbeDirectories(environment);

            result.Should().Contain(PackagesPath);
        }
Beispiel #7
0
        public void ShouldUseEnvironmentVariableToGetDefaultLocation()
        {
            var environment = EnvironmentMockBuilder.Create()
                              .AddVariable("NUGET_PACKAGES", PackagesPath)
                              .Build();

            var result = PackageCompilationAssemblyResolver.GetDefaultProbeDirectories(environment);

            // The host for .NET Core 2.0 always sets the PROBING_DIRECTORIES property on the AppContext. Because of that,
            // no additional package directories should be returned from this, even if they are set as environment variables.
            result.Should().NotContain(PackagesPath);
        }
Beispiel #8
0
        public void ShouldUseNugetUnderHomeOnNonWindows()
        {
            var environment = EnvironmentMockBuilder.Create()
                              .SetIsWindows(false)
                              .AddVariable("HOME", "User Home")
                              .AddAppContextData("PROBING_DIRECTORIES", string.Empty)
                              .Build();

            var result = PackageCompilationAssemblyResolver.GetDefaultProbeDirectories(environment);

            result.Should().Contain(Path.Combine("User Home", ".nuget", "packages"));
        }
Beispiel #9
0
        public void ShouldUseNugetUnderHomeOnNonWindows()
        {
            var environment = EnvironmentMockBuilder.Create()
                              .AddVariable("HOME", "User Home")
                              .Build();

            var result = PackageCompilationAssemblyResolver.GetDefaultProbeDirectories(Platform.Linux, environment);

            // The host for .NET Core 2.0 always sets the PROBING_DIRECTORIES property on the AppContext. Because of that,
            // no additional package directories should be returned from this, even if they are set as environment variables.
            result.Should().NotContain(Path.Combine("User Home", ".nuget", "packages"));
        }
        public void ReturnsProgramFilesAsDefaultLocationOnWin32()
        {
            var runtime = new Mock <IRuntimeEnvironment>();

            runtime.SetupGet(r => r.OperatingSystemPlatform).Returns(Platform.Windows);

            var environment = EnvironmentMockBuilder.Create()
                              .AddVariable("ProgramFiles", "Program Files")
                              .Build();

            var result = ReferenceAssemblyPathResolver.GetDefaultReferenceAssembliesPath(runtime.Object, FileSystemMockBuilder.Empty, environment);

            result.Should().Be(Path.Combine("Program Files", "Reference Assemblies", "Microsoft", "Framework"));
        }
        public void UsesEnvironmentVariableForDefaultPath()
        {
            var runtime = new Mock <IRuntimeEnvironment>();

            runtime.SetupGet(r => r.OperatingSystemPlatform).Returns(Platform.Windows);

            var environment = EnvironmentMockBuilder.Create()
                              .AddVariable("DOTNET_REFERENCE_ASSEMBLIES_PATH", ReferencePath)
                              .Build();

            var result = ReferenceAssemblyPathResolver.GetDefaultReferenceAssembliesPath(runtime.Object, FileSystemMockBuilder.Empty, environment);

            result.Should().Be(ReferencePath);
        }
Beispiel #12
0
        public void SholdUseNugetUnderHomeOnNonWindows()
        {
            var runtime = new Mock <IRuntimeEnvironment>();

            runtime.SetupGet(r => r.OperatingSystemPlatform).Returns(Platform.Linux);

            var environment = EnvironmentMockBuilder.Create()
                              .AddVariable("HOME", "User Home")
                              .Build();

            var result = PackageCompilationAssemblyResolver.GetDefaultPackageDirectory(runtime.Object, environment);

            result.Should().Be(Path.Combine("User Home", ".nuget", "packages"));
        }
        public void ReturnNet20PathAsFallbackOnWindows()
        {
            var net20Path  = Path.Combine("Windows", "Microsoft.NET", "Framework", "v2.0.50727");
            var fileSystem = FileSystemMockBuilder.Create()
                             .AddFiles(net20Path, "some.dll")
                             .Build();

            var environment = EnvironmentMockBuilder.Create()
                              .AddVariable("WINDIR", "Windows")
                              .Build();

            var result = ReferenceAssemblyPathResolver.GetFallbackSearchPaths(fileSystem, Platform.Windows, environment);

            result.Should().Contain(net20Path);
        }
Beispiel #14
0
 private IEnvironment GetDefaultEnvironment()
 {
     return(EnvironmentMockBuilder.Create()
            .AddVariable("DOTNET_PACKAGES_CACHE", CachePath)
            .Build());
 }