Skip to content

Commit 595a3ca

Browse files
yorahnulltoken
authored andcommitted
Make RepositoryInformation mockable
1 parent 1040c5e commit 595a3ca

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

LibGit2Sharp/RepositoryInformation.cs

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@ public class RepositoryInformation
99
{
1010
private readonly Repository repo;
1111

12+
/// <summary>
13+
/// Needed for mocking purposes.
14+
/// </summary>
15+
protected RepositoryInformation()
16+
{ }
17+
1218
internal RepositoryInformation(Repository repo, bool isBare)
1319
{
1420
this.repo = repo;
@@ -24,44 +30,44 @@ internal RepositoryInformation(Repository repo, bool isBare)
2430
/// <summary>
2531
/// Gets the normalized path to the git repository.
2632
/// </summary>
27-
public string Path { get; private set; }
33+
public virtual string Path { get; private set; }
2834

2935
/// <summary>
3036
/// Gets the normalized path to the working directory.
3137
/// <para>
3238
/// Is the repository is bare, null is returned.
3339
/// </para>
3440
/// </summary>
35-
public string WorkingDirectory { get; private set; }
41+
public virtual string WorkingDirectory { get; private set; }
3642

3743
/// <summary>
3844
/// Indicates whether the repository has a working directory.
3945
/// </summary>
40-
public bool IsBare { get; private set; }
46+
public virtual bool IsBare { get; private set; }
4147

4248
/// <summary>
4349
/// Gets a value indicating whether this repository is empty.
4450
/// </summary>
4551
/// <value>
4652
/// <c>true</c> if this repository is empty; otherwise, <c>false</c>.
4753
/// </value>
48-
public bool IsEmpty
54+
public virtual bool IsEmpty
4955
{
5056
get { return NativeMethods.RepositoryStateChecker(repo.Handle, NativeMethods.git_repository_is_empty); }
5157
}
5258

5359
/// <summary>
5460
/// Indicates whether the Head points to an arbitrary commit instead of the tip of a local branch.
5561
/// </summary>
56-
public bool IsHeadDetached
62+
public virtual bool IsHeadDetached
5763
{
5864
get { return NativeMethods.RepositoryStateChecker(repo.Handle, NativeMethods.git_repository_head_detached); }
5965
}
6066

6167
/// <summary>
6268
/// Indicates whether the Head points to a reference which doesn't exist.
6369
/// </summary>
64-
public bool IsHeadOrphaned
70+
public virtual bool IsHeadOrphaned
6571
{
6672
get { return NativeMethods.RepositoryStateChecker(repo.Handle, NativeMethods.git_repository_head_orphan); }
6773
}

0 commit comments

Comments
 (0)