コード例 #1
0
            public void Should_Create_Directory_For_Installed_Package()
            {
                // Given
                var fixture = new OutOfProcessFixture();

                // When
                fixture.Install();

                // Then
                Assert.True(fixture.FileSystem.GetDirectory("/Working/nuget/cake.foo.1.2.3").Exists);
            }
コード例 #2
0
            public void Should_Create_Install_Directory_If_It_Do_Not_Exist()
            {
                // Given
                var fixture = new OutOfProcessFixture();

                // When
                fixture.Install();

                // Then
                Assert.True(fixture.FileSystem.GetDirectory("/Working/nuget").Exists);
            }
コード例 #3
0
            public void Should_Use_Custom_Source_If_RelativeUri_Is_Used()
            {
                var fixture = new OutOfProcessFixture();

                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);
            }
コード例 #4
0
            public void Should_Throw_If_Install_Path_Is_Null()
            {
                // Given
                var fixture = new OutOfProcessFixture();

                fixture.InstallPath = null;

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

                // Then
                AssertEx.IsArgumentNullException(result, "path");
            }
コード例 #5
0
            public void Should_Use_NoCache_Flag_If_Parameter_Is_Used()
            {
                var fixture = new OutOfProcessFixture();

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

                // 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")));
            }
コード例 #6
0
            public void Should_Delete_Installation_Directory_If_Installation_Failed()
            {
                // Given
                var fixture = new OutOfProcessFixture();

                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);
            }
コード例 #7
0
            public void Should_Look_For_Files_In_The_Correct_Directory(string uri, string path)
            {
                // Given
                var fixture = new OutOfProcessFixture();

                fixture.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>());
            }
コード例 #8
0
            public void Should_Install_Resource()
            {
                // Given
                var fixture = new OutOfProcessFixture();

                // 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.1.2.3\" " +
                                             "-Source \"https://myget.org/temp/\" " +
                                             "-Version \"1.2.3\" " +
                                             "-Prerelease " +
                                             "-ExcludeVersion " +
                                             "-NonInteractive"));
            }
コード例 #9
0
            public void Should_Not_Install_If_Resource_Already_Is_Installed()
            {
                // Given
                var fixture = new OutOfProcessFixture();

                fixture.FileSystem.CreateDirectory("/Working/nuget/cake.foo.1.2.3/Cake.Foo");
                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");
            }
コード例 #10
0
            public void Should_Install_Resource_Without_Version_Number_If_None_Is_Provided()
            {
                // Given
                var fixture = new OutOfProcessFixture();

                fixture.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"));
            }
コード例 #11
0
            public void Should_Return_Correct_Files_When_Resource_Has_Dependencies()
            {
                // Given
                var fixture = new OutOfProcessFixture();

                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);
            }
コード例 #12
0
            public void Should_Use_Explicit_NuGet_Config_If_Set()
            {
                // Given
                var fixture = new OutOfProcessFixture();

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

                // 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.1.2.3\" " +
                                             "-Source \"https://myget.org/temp/\" " +
                                             "-ConfigFile \"/Working/nuget.config\" " +
                                             "-Version \"1.2.3\" " +
                                             "-Prerelease " +
                                             "-ExcludeVersion " +
                                             "-NonInteractive"));
            }