Skip to content

Commit

Permalink
Make Blob mockable
Browse files Browse the repository at this point in the history
  • Loading branch information
yorah committed Jun 17, 2012
1 parent 4985376 commit d9f60de
Showing 1 changed file with 9 additions and 21 deletions.
30 changes: 9 additions & 21 deletions LibGit2Sharp/Blob.cs
Expand Up @@ -14,6 +14,12 @@ public class Blob : GitObject
{
private readonly Repository repo;

/// <summary>
/// Needed for mocking purposes.
/// </summary>
protected Blob()
{ }

internal Blob(Repository repo, ObjectId id)
: base(id)
{
Expand All @@ -23,12 +29,12 @@ internal Blob(Repository repo, ObjectId id)
/// <summary>
/// Gets the size in bytes of the contents of a blob
/// </summary>
public int Size { get; set; }
public virtual int Size { get; set; }

/// <summary>
/// Gets the blob content in a <see cref="byte" /> array.
/// </summary>
public byte[] Content
public virtual byte[] Content
{
get
{
Expand All @@ -44,7 +50,7 @@ public byte[] Content
/// <summary>
/// Gets the blob content in a <see cref="Stream" />.
/// </summary>
public Stream ContentStream
public virtual Stream ContentStream
{
get
{
Expand All @@ -59,24 +65,6 @@ public Stream ContentStream
}
}

/// <summary>
/// Gets the blob content decoded as UTF-8.
/// </summary>
/// <returns></returns>
public string ContentAsUtf8()
{
return Encoding.UTF8.GetString(Content);
}

/// <summary>
/// Gets the blob content decoded as Unicode.
/// </summary>
/// <returns></returns>
public string ContentAsUnicode()
{
return Encoding.Unicode.GetString(Content);
}

internal static Blob BuildFromPtr(GitObjectSafeHandle obj, ObjectId id, Repository repo)
{
var blob = new Blob(repo, id)
Expand Down

0 comments on commit d9f60de

Please sign in to comment.