Skip to content
Merged
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
21 changes: 3 additions & 18 deletions GVFS/GVFS.Common/GVFSEnlistment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ public partial class GVFSEnlistment : Enlistment
private string gitVersion;
private string gvfsVersion;
private string gvfsHooksVersion;
private GitProcess gitProcess;

// New enlistment
public GVFSEnlistment(string enlistmentRoot, string repoUrl, string gitBinPath, string gvfsHooksRoot, GitAuthentication authentication)
Expand Down Expand Up @@ -252,25 +251,11 @@ private void CreateHiddenDirectory(string path)

private string GetId(string key)
{
GitProcess.ConfigResult configResult = this.GetGitProcess().GetFromLocalConfig(key);
GitProcess.ConfigResult configResult = this.CreateGitProcess().GetFromLocalConfig(key);
string value;
string error;
if (!configResult.TryParseAsString(out value, out error, defaultValue: string.Empty))
{
return value.Trim();
}

return string.Empty;
}

private GitProcess GetGitProcess()
{
if (this.gitProcess == null)
{
this.gitProcess = new GitProcess(this);
}

return this.gitProcess;
configResult.TryParseAsString(out value, out error, defaultValue: string.Empty);
return value.Trim();
}
}
}
52 changes: 52 additions & 0 deletions GVFS/GVFS.UnitTests/Common/GVFSEnlistmentTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
using GVFS.Common;
using GVFS.Common.Git;
using GVFS.Tests.Should;
using GVFS.UnitTests.Mock.Common;
using GVFS.UnitTests.Mock.Git;
using NUnit.Framework;

namespace GVFS.UnitTests.Common
{
[TestFixture]
public class GVFSEnlistmentTests
{
private const string MountId = "85576f54f9ab4388bcdc19b4f6c17696";
private const string EnlistmentId = "520dcf634ce34065a06abaa4010a256f";

[TestCase]
public void CanGetMountId()
{
TestGVFSEnlistment enlistment = new TestGVFSEnlistment();
enlistment.GetMountId().ShouldEqual(MountId);
}

[TestCase]
public void CanGetEnlistmentId()
{
TestGVFSEnlistment enlistment = new TestGVFSEnlistment();
enlistment.GetEnlistmentId().ShouldEqual(EnlistmentId);
}

private class TestGVFSEnlistment : GVFSEnlistment
{
private MockGitProcess gitProcess;

public TestGVFSEnlistment()
: base("mock:\\path", "mock://repoUrl", "mock:\\git", gvfsHooksRoot: null, authentication: null)
{
this.gitProcess = new MockGitProcess();
this.gitProcess.SetExpectedCommandResult(
"config --local gvfs.mount-id",
() => new GitProcess.Result(MountId, string.Empty, GitProcess.Result.SuccessCode));
this.gitProcess.SetExpectedCommandResult(
"config --local gvfs.enlistment-id",
() => new GitProcess.Result(EnlistmentId, string.Empty, GitProcess.Result.SuccessCode));
}

public override GitProcess CreateGitProcess()
{
return this.gitProcess;
}
}
}
}