Skip to content

Commit b6274a1

Browse files
yorahnulltoken
authored andcommitted
Make Changes, ContentChanges and TreeEntryChanges mockable
1 parent 4a5000b commit b6274a1

File tree

3 files changed

+29
-11
lines changed

3 files changed

+29
-11
lines changed

LibGit2Sharp/Changes.cs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@ public abstract class Changes
99
{
1010
private readonly StringBuilder patchBuilder = new StringBuilder();
1111

12+
/// <summary>
13+
/// Needed for mocking purposes.
14+
/// </summary>
15+
protected Changes()
16+
{ }
17+
1218
internal void AppendToPatch(string patch)
1319
{
1420
patchBuilder.Append(patch);
@@ -17,24 +23,24 @@ internal void AppendToPatch(string patch)
1723
/// <summary>
1824
/// The number of lines added.
1925
/// </summary>
20-
public int LinesAdded { get; internal set; }
26+
public virtual int LinesAdded { get; internal set; }
2127

2228
/// <summary>
2329
/// The number of lines deleted.
2430
/// </summary>
25-
public int LinesDeleted { get; internal set; }
31+
public virtual int LinesDeleted { get; internal set; }
2632

2733
/// <summary>
2834
/// The patch corresponding to these changes.
2935
/// </summary>
30-
public string Patch
36+
public virtual string Patch
3137
{
3238
get { return patchBuilder.ToString(); }
3339
}
3440

3541
/// <summary>
3642
/// Determines if at least one side of the comparison holds binary content.
3743
/// </summary>
38-
public bool IsBinaryComparison { get; protected set; }
44+
public virtual bool IsBinaryComparison { get; protected set; }
3945
}
4046
}

LibGit2Sharp/ContentChanges.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@ namespace LibGit2Sharp
99
/// </summary>
1010
public class ContentChanges : Changes
1111
{
12+
/// <summary>
13+
/// Needed for mocking purposes.
14+
/// </summary>
15+
protected ContentChanges()
16+
{ }
17+
1218
internal ContentChanges(Repository repo, Blob oldBlob, Blob newBlob, GitDiffOptions options)
1319
{
1420
using (var osw1 = new ObjectSafeWrapper(oldBlob.Id, repo))

LibGit2Sharp/TreeEntryChanges.cs

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@ namespace LibGit2Sharp
77
/// </summary>
88
public class TreeEntryChanges : Changes
99
{
10+
/// <summary>
11+
/// Needed for mocking purposes.
12+
/// </summary>
13+
protected TreeEntryChanges()
14+
{ }
15+
1016
internal TreeEntryChanges(FilePath path, Mode mode, ObjectId oid, ChangeKind status, FilePath oldPath, Mode oldMode, ObjectId oldOid, bool isBinaryComparison)
1117
{
1218
Path = path.Native;
@@ -22,36 +28,36 @@ internal TreeEntryChanges(FilePath path, Mode mode, ObjectId oid, ChangeKind sta
2228
/// <summary>
2329
/// The new path.
2430
/// </summary>
25-
public string Path { get; private set; }
31+
public virtual string Path { get; private set; }
2632

2733
/// <summary>
2834
/// The new <see cref="Mode"/>.
2935
/// </summary>
30-
public Mode Mode { get; private set; }
36+
public virtual Mode Mode { get; private set; }
3137

3238
/// <summary>
3339
/// The new content hash.
3440
/// </summary>
35-
public ObjectId Oid { get; private set; }
41+
public virtual ObjectId Oid { get; private set; }
3642

3743
/// <summary>
3844
/// The kind of change that has been done (added, deleted, modified ...).
3945
/// </summary>
40-
public ChangeKind Status { get; private set; }
46+
public virtual ChangeKind Status { get; private set; }
4147

4248
/// <summary>
4349
/// The old path.
4450
/// </summary>
45-
public string OldPath { get; private set; }
51+
public virtual string OldPath { get; private set; }
4652

4753
/// <summary>
4854
/// The old <see cref="Mode"/>.
4955
/// </summary>
50-
public Mode OldMode { get; private set; }
56+
public virtual Mode OldMode { get; private set; }
5157

5258
/// <summary>
5359
/// The old content hash.
5460
/// </summary>
55-
public ObjectId OldOid { get; private set; }
61+
public virtual ObjectId OldOid { get; private set; }
5662
}
5763
}

0 commit comments

Comments
 (0)