Skip to content

Commit d9f60de

Browse files
committed
Make Blob mockable
1 parent 4985376 commit d9f60de

File tree

1 file changed

+9
-21
lines changed

1 file changed

+9
-21
lines changed

LibGit2Sharp/Blob.cs

Lines changed: 9 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@ public class Blob : GitObject
1414
{
1515
private readonly Repository repo;
1616

17+
/// <summary>
18+
/// Needed for mocking purposes.
19+
/// </summary>
20+
protected Blob()
21+
{ }
22+
1723
internal Blob(Repository repo, ObjectId id)
1824
: base(id)
1925
{
@@ -23,12 +29,12 @@ internal Blob(Repository repo, ObjectId id)
2329
/// <summary>
2430
/// Gets the size in bytes of the contents of a blob
2531
/// </summary>
26-
public int Size { get; set; }
32+
public virtual int Size { get; set; }
2733

2834
/// <summary>
2935
/// Gets the blob content in a <see cref="byte" /> array.
3036
/// </summary>
31-
public byte[] Content
37+
public virtual byte[] Content
3238
{
3339
get
3440
{
@@ -44,7 +50,7 @@ public byte[] Content
4450
/// <summary>
4551
/// Gets the blob content in a <see cref="Stream" />.
4652
/// </summary>
47-
public Stream ContentStream
53+
public virtual Stream ContentStream
4854
{
4955
get
5056
{
@@ -59,24 +65,6 @@ public Stream ContentStream
5965
}
6066
}
6167

62-
/// <summary>
63-
/// Gets the blob content decoded as UTF-8.
64-
/// </summary>
65-
/// <returns></returns>
66-
public string ContentAsUtf8()
67-
{
68-
return Encoding.UTF8.GetString(Content);
69-
}
70-
71-
/// <summary>
72-
/// Gets the blob content decoded as Unicode.
73-
/// </summary>
74-
/// <returns></returns>
75-
public string ContentAsUnicode()
76-
{
77-
return Encoding.Unicode.GetString(Content);
78-
}
79-
8068
internal static Blob BuildFromPtr(GitObjectSafeHandle obj, ObjectId id, Repository repo)
8169
{
8270
var blob = new Blob(repo, id)

0 commit comments

Comments
 (0)