Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions Cake.MsDeploy.slnx
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
<Solution>
<Folder Name="/.props/">
<File Path=".editorconfig" />
<File Path=".gitattributes" />
<File Path=".gitignore" />
</Folder>
<Project Path="src/Cake.MsDeploy.Tests/Cake.MsDeploy.Tests.csproj" />
<Project Path="src/Cake.MsDeploy/Cake.MsDeploy.csproj" />
</Solution>
8 changes: 4 additions & 4 deletions src/Cake.MsDeploy.Tests/Cake.MsDeploy.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@
<None Remove="Properties\**" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Cake.Core" Version="5.0.0" />
<PackageReference Include="Cake.Testing" Version="5.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.14.0" />
<PackageReference Include="Cake.Core" Version="5.1.0" />
<PackageReference Include="Cake.Testing" Version="5.1.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.0.0" />
<PackageReference Include="NSubstitute" Version="5.3.0" />
<PackageReference Include="xunit" Version="2.9.3" />
<PackageReference Include="xunit.runner.visualstudio" Version="3.1.0" PrivateAssets="all" IncludeAssets="runtime; build; native; contentfiles; analyzers; buildtransitive" />
<PackageReference Include="xunit.runner.visualstudio" Version="3.1.5" PrivateAssets="all" IncludeAssets="runtime; build; native; contentfiles; analyzers; buildtransitive" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Cake.MsDeploy\Cake.MsDeploy.csproj" />
Expand Down
33 changes: 16 additions & 17 deletions src/Cake.MsDeploy.Tests/Unit/Directives/SkipDIrectiveTests.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
using Cake.MsDeploy.Directives;
using System.Collections.Generic;
using System.Collections.Generic;
using Cake.MsDeploy.Directives;
using Xunit;

namespace Cake.MsDeploy.Tests.Unit.Directives
{
public class SkipDirectiveTests
public static class SkipDirectiveTests
{
public sealed class TheToCommandLineArgument
{
Expand All @@ -15,22 +15,21 @@ public void Should_Throw_If_Context_Is_Null()
var rule = new SkipDirective();

// When
var result = Record.Exception(() => rule.AppendCommandLineArgument(null));
var result = Record.Exception(() => rule.AppendCommandLineArgument(null!));

// Then
AssertEx.IsArgumentNullException(result, "sb");
}


[Theory]
[MemberData(nameof(SkipDirectiveData))]
public void Should_Append_Options(SkipDirective directive, string expected)
{
//Given --> When
// Given --> When
var actual = directive.ToCommandLineArgument();

//Then
Assert.Equal(expected, directive.ToCommandLineArgument());
// Then
Assert.Equal(expected, actual);
}

public static IEnumerable<object[]> SkipDirectiveData()
Expand All @@ -39,33 +38,33 @@ public static IEnumerable<object[]> SkipDirectiveData()
{
new object[]
{
new SkipDirective { ObjectName = "contentPath", AbsolutePath = "C:\\fake\\path" }, // <------------- Indivdual Property to test
new SkipDirective { ObjectName = "contentPath", AbsolutePath = "C:\\fake\\path" }, // <------------- Indivdual Property to test
"-skip:objectName=contentPath,absolutePath=\"C:\\fake\\path\"", // <------------- Expected Result
},

new object[]
{
new SkipDirective { SkipAction = SkipAction.Update, ObjectName = "windowsAuthentication" }, // <------------- Indivdual Property to test
new SkipDirective { SkipAction = SkipAction.Update, ObjectName = "windowsAuthentication" }, // <------------- Indivdual Property to test
"-skip:skipAction=Update,objectName=windowsAuthentication", // <------------- Expected Result
},

new object[]
{
new SkipDirective { ObjectName = "webConfig", KeyAttribute = "Key attribute"}, // <------------- Indivdual Property to test
new SkipDirective { ObjectName = "webConfig", KeyAttribute = "Key attribute" }, // <------------- Indivdual Property to test
"-skip:objectName=webConfig,keyAttribute=\"Key attribute\"", // <------------- Expected Result
},

new object[]
{
new SkipDirective { ObjectName = "destPath", XPath = "/web.config" }, // <------------- Indivdual Property to test
"-skip:objectName=destPath,xPath=\"/web.config\"", // <------------- Expected Result
new SkipDirective { ObjectName = "destPath", XPath = "/web.config" }, // <------------- Indivdual Property to test
"-skip:objectName=destPath,xPath=\"/web.config\"", // <------------- Expected Result
},

new object[]
{
new SkipDirective { ObjectName = "virtualdirectory", SkipAction = SkipAction.Update, AbsolutePath = "C:\\wwwroot", XPath = "//web.config", KeyAttribute = "Description"}, // <------------- Combined Properties to test
"-skip:skipAction=Update,objectName=virtualdirectory,absolutePath=\"C:\\wwwroot\",xPath=\"//web.config\",keyAttribute=\"Description\"" // <------------- Expected Result
}
new SkipDirective { ObjectName = "virtualdirectory", SkipAction = SkipAction.Update, AbsolutePath = "C:\\wwwroot", XPath = "//web.config", KeyAttribute = "Description" }, // <------------- Combined Properties to test
"-skip:skipAction=Update,objectName=virtualdirectory,absolutePath=\"C:\\wwwroot\",xPath=\"//web.config\",keyAttribute=\"Description\"", // <------------- Expected Result
},
};
}
}
Expand Down
9 changes: 4 additions & 5 deletions src/Cake.MsDeploy.Tests/Unit/MsDeployAliasesTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

namespace Cake.MsDeploy.Tests.Unit
{

public sealed class MsDeployAliasesTests
{
public sealed class TheMsDeployMethod
Expand All @@ -16,10 +15,10 @@ public void Should_Throw_If_Context_Is_Null()
var context = Substitute.For<ICakeContext>();

// When
var result = Record.Exception(() => MsDeployAliases.MsDeploy(null, null));
var result = Record.Exception(() => MsDeployAliases.MsDeploy(null!, null!));

// Then
AssertEx.IsArgumentNullException(result, "context");
AssertEx.IsArgumentNullException(result, nameof(context));
}

[Fact]
Expand All @@ -29,11 +28,11 @@ public void Should_Throw_If_Settings_Is_Null()
var context = Substitute.For<ICakeContext>();

// When
var result = Record.Exception(() => MsDeployAliases.MsDeploy(context, null));
var result = Record.Exception(() => MsDeployAliases.MsDeploy(context, null!));

// Then
AssertEx.IsArgumentNullException(result, "settings");
}
}
}
}
}
Loading