Пример #1
0
                public void Should_Replace_Template_Tokens_In_Nuspec_Without_Namespaces()
                {
                    // Given
                    var fixture = new NuGetPackerWithNuSpecFixture();

                    fixture.WithNuSpecXml(Resources.Nuspec_NoMetadataValues_WithoutNamespaces);

                    fixture.Settings.Id          = "The ID";
                    fixture.Settings.Version     = "The version";
                    fixture.Settings.Title       = "The title";
                    fixture.Settings.Authors     = new[] { "Author #1", "Author #2" };
                    fixture.Settings.Owners      = new[] { "Owner #1", "Owner #2" };
                    fixture.Settings.Description = "The description";
                    fixture.Settings.Summary     = "The summary";
                    fixture.Settings.LicenseUrl  = new Uri("https://license.com");
                    fixture.Settings.ProjectUrl  = new Uri("https://project.com");
                    fixture.Settings.IconUrl     = new Uri("https://icon.com");
                    fixture.Settings.RequireLicenseAcceptance = true;
                    fixture.Settings.Copyright    = "The copyright";
                    fixture.Settings.ReleaseNotes = new[] { "Line #1", "Line #2", "Line #3" };
                    fixture.Settings.Tags         = new[] { "Tag1", "Tag2", "Tag3" };

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

                    // Then
                    Assert.Equal(
                        Resources.Nuspec_Metadata_WithoutNamespaces.NormalizeLineEndings(),
                        result.NuspecContent.NormalizeLineEndings());
                }
Пример #2
0
                public void Should_Add_Metadata_Element_To_Nuspec_If_Missing()
                {
                    // Given
                    var fixture = new NuGetPackerWithNuSpecFixture();

                    fixture.WithNuSpecXml(Resources.Nuspec_NoMetadataElement);

                    fixture.Settings.Id                       = "The ID";
                    fixture.Settings.Version                  = "The version";
                    fixture.Settings.Title                    = "The title";
                    fixture.Settings.Authors                  = new[] { "Author #1", "Author #2" };
                    fixture.Settings.Owners                   = new[] { "Owner #1", "Owner #2" };
                    fixture.Settings.Description              = "The description";
                    fixture.Settings.Summary                  = "The summary";
                    fixture.Settings.LicenseUrl               = new Uri("https://license.com");
                    fixture.Settings.ProjectUrl               = new Uri("https://project.com");
                    fixture.Settings.IconUrl                  = new Uri("https://icon.com");
                    fixture.Settings.DevelopmentDependency    = true;
                    fixture.Settings.RequireLicenseAcceptance = true;
                    fixture.Settings.Copyright                = "The copyright";
                    fixture.Settings.ReleaseNotes             = new[] { "Line #1", "Line #2", "Line #3" };
                    fixture.Settings.Tags                     = new[] { "Tag1", "Tag2", "Tag3" };
                    fixture.Settings.Language                 = "en-us";

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

                    // Then
                    Assert.Equal(
                        Resources.Nuspec_Metadata.NormalizeLineEndings(),
                        result.NuspecContent.NormalizeLineEndings());
                }
Пример #3
0
                public void Should_Replace_Template_Tokens_In_Nuspec_With_Files_And_DependencyTargetFramework_Without_Namespaces()
                {
                    // Given
                    var fixture = new NuGetPackerWithNuSpecFixture();

                    fixture.WithNuSpecXml(Resources.Nuspec_NoMetadataValues_WithoutNamespaces);

                    fixture.Settings.Id                       = "The ID";
                    fixture.Settings.Version                  = "The version";
                    fixture.Settings.Title                    = "The title";
                    fixture.Settings.Authors                  = new[] { "Author #1", "Author #2" };
                    fixture.Settings.Owners                   = new[] { "Owner #1", "Owner #2" };
                    fixture.Settings.Description              = "The description";
                    fixture.Settings.Summary                  = "The summary";
                    fixture.Settings.LicenseUrl               = new Uri("https://license.com");
                    fixture.Settings.ProjectUrl               = new Uri("https://project.com");
                    fixture.Settings.IconUrl                  = new Uri("https://icon.com");
                    fixture.Settings.DevelopmentDependency    = true;
                    fixture.Settings.RequireLicenseAcceptance = true;
                    fixture.Settings.Copyright                = "The copyright";
                    fixture.Settings.ReleaseNotes             = new[] { "Line #1", "Line #2", "Line #3" };
                    fixture.Settings.Tags                     = new[] { "Tag1", "Tag2", "Tag3" };
                    fixture.Settings.Language                 = "en-us";
                    fixture.Settings.Files                    = new[]
                    {
                        new NuSpecContent {
                            Source = "Cake.Core.dll", Target = "lib/net45"
                        },
                        new NuSpecContent {
                            Source = "Cake.Core.xml", Target = "lib/net45"
                        },
                        new NuSpecContent {
                            Source = "Cake.Core.pdb", Target = "lib/net45"
                        },
                        new NuSpecContent {
                            Source = "LICENSE"
                        }
                    };
                    fixture.Settings.Dependencies = new[]
                    {
                        new NuSpecDependency {
                            Id = "Test1", Version = "1.0.0", TargetFramework = "net452"
                        },
                        new NuSpecDependency {
                            Id = "Test2", Version = "[1.0.0]", TargetFramework = "net46"
                        }
                    };

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

                    // Then
                    Assert.Equal(
                        Resources.Nuspec_Metadata_WithoutNamespaces_WithTargetFramworkDependencies.NormalizeLineEndings(),
                        result.NuspecContent.NormalizeLineEndings());
                }
Пример #4
0
                public void Should_Delete_Transformed_Nuspec()
                {
                    // Given
                    var fixture = new NuGetPackerWithNuSpecFixture();

                    // When
                    fixture.Run();

                    // Then
                    Assert.False(fixture.FileSystem.Exist((FilePath)"/Working/existing.temp.nuspec"));
                }
Пример #5
0
                public void Should_Find_NuGet_Executable_If_Tool_Path_Not_Provided()
                {
                    // Given
                    var fixture = new NuGetPackerWithNuSpecFixture();

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

                    // Then
                    Assert.Equal("/Working/tools/NuGet.exe", result.Path.FullPath);
                }
Пример #6
0
                public void Should_Throw_If_Nuspec_Do_Not_Exist()
                {
                    // Given
                    var fixture = new NuGetPackerWithNuSpecFixture();

                    fixture.NuSpecFilePath = "./nonexisting.nuspec";

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

                    // Then
                    Assert.IsCakeException(result, "Could not find nuspec file '/Working/nonexisting.nuspec'.");
                }
Пример #7
0
                public void Should_Throw_If_Process_Has_A_Non_Zero_Exit_Code()
                {
                    // Given
                    var fixture = new NuGetPackerWithNuSpecFixture();

                    fixture.GivenProcessExitsWithCode(1);

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

                    // Then
                    Assert.IsCakeException(result, "NuGet: Process returned an error (exit code 1).");
                }
Пример #8
0
                public void Should_Throw_If_Process_Was_Not_Started()
                {
                    // Given
                    var fixture = new NuGetPackerWithNuSpecFixture();

                    fixture.GivenProcessCannotStart();

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

                    // Then
                    Assert.IsCakeException(result, "NuGet: Process was not started.");
                }
Пример #9
0
                public void Should_Keep_NuSpec_File_According_To_Flag(bool keepTemporaryNuSpecFile)
                {
                    // Given
                    var fixture = new NuGetPackerWithNuSpecFixture();

                    fixture.Settings.KeepTemporaryNuSpecFile = keepTemporaryNuSpecFile;

                    // When
                    fixture.Run();

                    // Then
                    Assert.Equal(keepTemporaryNuSpecFile, fixture.FileSystem.Exist((FilePath)"/Working/existing.temp.nuspec"));
                }
Пример #10
0
                public void Should_Add_MSBuildVersion_To_Arguments_If_Set(NuGetMSBuildVersion msBuildVersion, string expected)
                {
                    // Given
                    var fixture = new NuGetPackerWithNuSpecFixture();

                    fixture.Settings.MSBuildVersion = msBuildVersion;

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

                    // Then
                    Assert.Equal(expected, result.Args);
                }
Пример #11
0
                public void Should_Add_Version_To_Arguments_If_Not_Null()
                {
                    // Given
                    var fixture = new NuGetPackerWithNuSpecFixture();

                    fixture.Settings.Version = "1.0.0";

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

                    // Then
                    Assert.Equal("pack -Version \"1.0.0\" \"/Working/existing.temp.nuspec\"", result.Args);
                }
Пример #12
0
                public void Should_Throw_If_NuGet_Executable_Was_Not_Found()
                {
                    // Given
                    var fixture = new NuGetPackerWithNuSpecFixture();

                    fixture.GivenDefaultToolDoNotExist();

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

                    // Then
                    Assert.IsCakeException(result, "NuGet: Could not locate executable.");
                }
Пример #13
0
                public void Should_Add_Verbosity_To_Arguments_If_Set(NuGetVerbosity verbosity, string expected)
                {
                    // Given
                    var fixture = new NuGetPackerWithNuSpecFixture();

                    fixture.Settings.Verbosity = verbosity;

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

                    // Then
                    Assert.Equal(expected, result.Args);
                }
Пример #14
0
                public void Should_Throw_If_Settings_Is_Null()
                {
                    // Given
                    var fixture = new NuGetPackerWithNuSpecFixture();

                    fixture.Settings = null;

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

                    // Then
                    Assert.IsArgumentNullException(result, "settings");
                }
Пример #15
0
                public void Should_Add_Symbols_Flag_To_Arguments_If_Set()
                {
                    // Given
                    var fixture = new NuGetPackerWithNuSpecFixture();

                    fixture.Settings.Symbols = true;

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

                    // Then
                    Assert.Equal("pack \"/Working/existing.temp.nuspec\" -Symbols", result.Args);
                }
Пример #16
0
                public void Should_Throw_If_Nuspec_File_Path_Is_Null()
                {
                    // Given
                    var fixture = new NuGetPackerWithNuSpecFixture();

                    fixture.NuSpecFilePath = null;

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

                    // Then
                    Assert.IsArgumentNullException(result, "filePath");
                }
Пример #17
0
                public void Should_Use_NuGet_Executable_From_Tool_Path_If_Provided_On_Windows(string toolPath, string expected)
                {
                    // Given
                    var fixture = new NuGetPackerWithNuSpecFixture();

                    fixture.Settings.ToolPath = toolPath;
                    fixture.GivenSettingsToolPathExist();

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

                    // Then
                    Assert.Equal(expected, result.Path.FullPath);
                }
Пример #18
0
                public void Should_Throw_If_Temporary_Nuspec_Already_Exist()
                {
                    // Given
                    var fixture = new NuGetPackerWithNuSpecFixture();

                    fixture.GivenTemporaryNuSpecAlreadyExist();

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

                    // Then
                    Assert.IsCakeException(result,
                                           "Could not create the nuspec file '/Working/existing.temp.nuspec' since it already exist.");
                }
Пример #19
0
                public void Should_Add_Output_Directory_To_Arguments_If_Not_Null()
                {
                    // Given
                    var fixture = new NuGetPackerWithNuSpecFixture();

                    fixture.Settings.OutputDirectory = "./build/output";

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

                    // Then
                    Assert.Equal("pack -OutputDirectory \"/Working/build/output\" " +
                                 "\"/Working/existing.temp.nuspec\"", result.Args);
                }
Пример #20
0
                public void Should_Add_Base_Path_To_Arguments_If_Not_Null()
                {
                    // Given
                    var fixture = new NuGetPackerWithNuSpecFixture();

                    fixture.Settings.BasePath = "./build";

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

                    // Then
                    Assert.Equal("pack -BasePath \"/Working/build\" " +
                                 "\"/Working/existing.temp.nuspec\"", result.Args);
                }