Esempio n. 1
0
            public void Should_Create_Install_Directory_If_It_Do_Not_Exist()
            {
                // Given
                var fixture = new NuGetPackageInstallerFixture();

                // When
                fixture.Install();

                // Then
                Assert.True(fixture.FileSystem.GetDirectory("/Working/nuget").Exists);
            }
            public void Should_Create_Directory_For_Installed_Package()
            {
                // Given
                var fixture = new NuGetPackageInstallerFixture();

                // When
                fixture.Install();

                // Then
                Assert.True(fixture.FileSystem.GetDirectory("/Working/nuget/cake.foo.1.2.3").Exists);
            }
Esempio n. 3
0
            public void Should_Throw_If_Install_Path_Is_Null()
            {
                // Given
                var fixture = new NuGetPackageInstallerFixture();

                fixture.InstallPath = null;

                // When
                var result = Record.Exception(() => fixture.Install());

                // Then
                Assert.IsArgumentNullException(result, "path");
            }
Esempio n. 4
0
            public void Should_Use_Custom_Source_If_RelativeUri_Is_Used()
            {
                var fixture = new NuGetPackageInstallerFixture();

                fixture.Package = new PackageReference("nuget:?package=Cake.Core");

                // When
                var result = Record.Exception(() => fixture.Install());

                // Then
                Assert.Null(result);
                fixture.Config.Received().GetValue(NUGET_CONFIGKEY);
            }
            public void Should_Delete_Installation_Directory_If_Installation_Failed()
            {
                // Given
                var fixture = new NuGetPackageInstallerFixture();
                var process = Substitute.For <IProcess>();

                process.GetExitCode().Returns(128);
                fixture.ProcessRunner.Start(Arg.Any <FilePath>(), Arg.Any <ProcessSettings>()).Returns(process);

                // When
                fixture.Install();

                // Then
                Assert.False(fixture.FileSystem.GetDirectory("/Working/nuget/cake.foo.1.2.3").Exists);
            }
Esempio n. 6
0
            public void Should_Not_Use_NoCache_Flag_If_Parameter_Is_Not_Used()
            {
                var fixture = new NuGetPackageInstallerFixture();

                fixture.Package = new PackageReference("nuget:?package=Cake.Core");

                // When
                var result = Record.Exception(() => fixture.Install());

                // Then
                Assert.Null(result);
                fixture.ProcessRunner.Received(1).Start(
                    Arg.Any <FilePath>(),
                    Arg.Is <ProcessSettings>(settings =>
                                             !settings.Arguments.Render().Contains("-NoCache")));
            }
            public void Should_Look_For_Files_In_The_Correct_Directory(string uri, string path)
            {
                // Given
                var fixture = new NuGetPackageInstallerFixture()
                {
                    Package = new PackageReference(uri)
                };

                fixture.InstallPackageAtSpecifiedPath(path);

                // When
                fixture.Install();

                // Then
                fixture.ContentResolver.Received(1).GetFiles(
                    Arg.Is <DirectoryPath>(p => p.FullPath == path),
                    Arg.Any <PackageReference>(), Arg.Any <PackageType>());
            }
Esempio n. 8
0
            public void Should_Install_Resource()
            {
                // Given
                var fixture = new NuGetPackageInstallerFixture();

                // When
                fixture.Install();

                // Then
                fixture.ProcessRunner.Received(1).Start(
                    Arg.Is <FilePath>(path => path.FullPath == "/Working/tools/nuget.exe"),
                    Arg.Is <ProcessSettings>(settings =>
                                             settings.Arguments.Render() == "install \"Cake.Foo\" " +
                                             "-OutputDirectory \"/Working/nuget\" " +
                                             "-Source \"https://myget.org/temp/\" " +
                                             "-Version \"1.2.3\" " +
                                             "-Prerelease -ExcludeVersion " +
                                             "-NonInteractive"));
            }
Esempio n. 9
0
            public void Should_Not_Install_If_Resource_Already_Is_Installed()
            {
                // Given
                var fixture = new NuGetPackageInstallerFixture();

                fixture.ContentResolver.GetFiles(
                    Arg.Any <DirectoryPath>(), Arg.Any <PackageReference>(), Arg.Any <PackageType>())
                .Returns(new List <IFile> {
                    Substitute.For <IFile>()
                });

                // When
                fixture.Install();

                // Then
                fixture.Log.Received(1).Write(
                    Verbosity.Diagnostic, LogLevel.Debug,
                    "Package {0} has already been installed.",
                    "Cake.Foo");
            }
            public void Should_Use_Explicit_NuGet_Config_If_Set()
            {
                var fixture = new NuGetPackageInstallerFixture();

                fixture.Config.GetValue(Arg.Is(Constants.NuGet.ConfigFile)).Returns("/Working/nuget.config");

                fixture.Install();

                fixture.ProcessRunner.Received(1).Start(
                    Arg.Is <FilePath>(path => path.FullPath == "/Working/tools/nuget.exe"),
                    Arg.Is <ProcessSettings>(settings =>
                                             settings.Arguments.Render() ==
                                             "install \"Cake.Foo\" " +
                                             "-OutputDirectory \"/Working/nuget/cake.foo.1.2.3\" " +
                                             "-Source \"https://myget.org/temp/\" " +
                                             "-ConfigFile \"/Working/nuget.config\" " +
                                             "-Version \"1.2.3\" " +
                                             "-Prerelease " +
                                             "-ExcludeVersion " +
                                             "-NonInteractive"));
            }
Esempio n. 11
0
            public void Should_Install_Resource_Without_Version_Number_If_None_Is_Provided()
            {
                // Given
                var fixture = new NuGetPackageInstallerFixture()
                {
                    Package = new PackageReference("nuget:https://myget.org/temp/?package=Cake.Foo&prerelease")
                };

                // When
                fixture.Install();

                // Then
                fixture.ProcessRunner.Received(1).Start(
                    Arg.Is <FilePath>(path => path.FullPath == "/Working/tools/nuget.exe"),
                    Arg.Is <ProcessSettings>(settings =>
                                             settings.Arguments.Render() == "install \"Cake.Foo\" " +
                                             "-OutputDirectory \"/Working/nuget/cake.foo\" " +
                                             "-Source \"https://myget.org/temp/\" " +
                                             "-Prerelease " +
                                             "-ExcludeVersion " +
                                             "-NonInteractive"));
            }
Esempio n. 12
0
            public void Should_Return_Correct_Files_When_Resource_Has_Dependencies()
            {
                // Given
                var fixture = new NuGetPackageInstallerFixture();

                fixture.FileSystem.CreateFile("/Working/nuget/cake.foo.1.2.3/Cake.Abc/Cake.Abc.dll");
                fixture.FileSystem.CreateFile("/Working/nuget/cake.foo.1.2.3/Cake.Foo/Cake.Foo.dll");
                fixture.FileSystem.CreateFile("/Working/nuget/cake.foo.1.2.3/Cake.Xyz/Cake.Xyz.dll");
                fixture.ContentResolver.GetFiles(
                    Arg.Any <DirectoryPath>(), Arg.Any <PackageReference>(), Arg.Any <PackageType>())
                .Returns(new List <IFile> {
                    Substitute.For <IFile>()
                });

                // When
                var result = fixture.Install();

                // Then
                fixture.ContentResolver.Received(1).GetFiles(
                    Arg.Is <DirectoryPath>(x => x.FullPath.Equals("/Working/nuget/cake.foo.1.2.3/Cake.Foo")),
                    fixture.Package,
                    PackageType.Addin);
            }