Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added SVN Revert command. #88

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/Cake.Svn.Tests/Cake.Svn.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
<Compile Include="Fixtures\Add\SvnAdderFixture.cs" />
<Compile Include="Fixtures\Export\SvnExporterFixture.cs" />
<Compile Include="Fixtures\Info\SvnInfoFixture.cs" />
<Compile Include="Fixtures\Revert\SvnRevertFixture.cs" />
<Compile Include="Fixtures\Status\SvnStatusFixture.cs" />
<Compile Include="Fixtures\Update\SvnUpdaterFixture.cs" />
<Compile Include="Fixtures\Vacuum\SvnVacuumFixture.cs" />
Expand All @@ -82,6 +83,8 @@
<Compile Include="Fixtures\Checkout\SvnCheckouterFixture.cs" />
<Compile Include="Unit\Checkout\SvnCheckouterTests.cs" />
<Compile Include="Unit\Checkout\SvnCheckoutSettingsTests.cs" />
<Compile Include="Unit\Revert\SvnReverterTests.cs" />
<Compile Include="Unit\Revert\SvnRevertSettingsTests.cs" />
<Compile Include="Unit\Status\SvnStatusSettingsTests.cs" />
<Compile Include="Unit\Status\SvnStatusTests.cs" />
<Compile Include="Unit\Update\SvnUpdaterTests.cs" />
Expand Down
120 changes: 120 additions & 0 deletions src/Cake.Svn.Tests/Fixtures/Revert/SvnRevertFixture.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
using System;
using System.Collections.Generic;
using Cake.Core;
using Cake.Core.IO;
using Cake.Svn.Revert;
using NSubstitute;

namespace Cake.Svn.Tests.Fixtures.Revert
{
internal sealed class SvnRevertFixture
{
internal ICakeEnvironment Environment { get; set; }
internal ISvnClient SvnClient { get; set; }
internal SvnRevertSettings Settings { get; set; }
internal FilePath FilePath { get; set; }
internal DirectoryPath DirectoryPath { get; set; }
internal FilePathCollection FilePaths { get; set; }
internal DirectoryPathCollection DirectoryPaths { get; set; }

internal Func<ISvnClient> GetSvnClient { get; set; }

internal ICollection<string> FilePathsAsStrings
{
get
{
var list = new List<string>();
if(FilePaths != null)
{
foreach(FilePath path in FilePaths)
{
list.Add(path.ToString());
}
}

return list;
}
}

internal ICollection<string> DirectoryPathsAsStrings
{
get
{
var list = new List<string>();
if(DirectoryPaths != null)
{
foreach(DirectoryPath path in DirectoryPaths)
{
list.Add(path.ToString());
}
}

return list;
}
}

internal SvnRevertFixture()
{
Environment = Substitute.For<ICakeEnvironment>();
SvnClient = Substitute.For<ISvnClient>();
Settings = new SvnRevertSettings();
FilePath = new FilePath(@"c:\repo\src\Program.cs");
DirectoryPath = new DirectoryPath(@"c:\repo\src\");
FilePaths = new FilePathCollection(
new List<FilePath>
{
new FilePath(@"c:\repo\src\Cake.Svn\Cake.Svn.csproj"),
new FilePath(@"c:\repo\src\Cake.Svn.Tests\Cake.Svn.Tests.csproj")
}
);
DirectoryPaths = new DirectoryPathCollection(
new List<DirectoryPath>
{
new DirectoryPath(@"c:\repo\src\Cake.Svn\"),
new DirectoryPath(@"c:\repo\src\Cake.Svn.Tests/")
}
);
GetSvnClient = () => SvnClient;
}

internal SvnReverter CreateReverter()
{
return new SvnReverter(Environment, GetSvnClient);
}

internal bool RevertFilePath()
{
var reverter = CreateReverter();

return reverter.Revert(FilePath, Settings);
}

internal bool RevertDirectoryPath()
{
var reverter = CreateReverter();

return reverter.Revert(DirectoryPath, Settings);
}

internal bool RevertFilePathCollection()
{
var reverter = CreateReverter();

return reverter.Revert(FilePaths, Settings);
}

internal bool RevertDirectoryPathCollection()
{
var reverter = CreateReverter();

return reverter.Revert(DirectoryPaths, Settings);
}

internal bool RevertFileAndDirectoryPathCollections()
{
var reverter = CreateReverter();

return reverter.Revert(FilePaths, DirectoryPaths, Settings);
}
}
}
56 changes: 56 additions & 0 deletions src/Cake.Svn.Tests/Unit/Revert/SvnRevertSettingsTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
using Cake.Svn.Revert;
using Xunit;

namespace Cake.Svn.Tests.Unit.Revert
{
public sealed class SvnRevertSettingsTests
{
/// <summary>
/// Ensures the constructor sets the settings
/// to the correct defaults, which are the same defaults
/// that SharpSVN uses.
/// </summary>
public sealed class TheConstructor
{
[Fact]
public void Should_ChangeLists_Be_Empty_By_default()
{
// Given, When
var settings = new SvnRevertSettings();

// Then
Assert.Equal(0, settings.ChangeLists.Count);
}

[Fact]
public void Should_MetaDataOnly_Be_False_By_default()
{
// Given, When
var settings = new SvnRevertSettings();

// Then
Assert.False(settings.MetaDataOnly);
}

[Fact]
public void Should_ClearChangeLists_Be_False_By_Default()
{
// Given, When
var settings = new SvnRevertSettings();

// Then
Assert.False(settings.ClearChangeLists);
}

[Fact]
public void Should_Depth_Be_Empty_By_Default()
{
// Given, When
var settings = new SvnRevertSettings();

// Then
Assert.Equal(SvnDepth.Empty, settings.Depth);
}
}
}
}