Skip to content

Commit

Permalink
Make CommitLog mockable
Browse files Browse the repository at this point in the history
  • Loading branch information
yorah authored and nulltoken committed Jun 18, 2012
1 parent 595a3ca commit d62ae53
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions LibGit2Sharp/CommitLog.cs
Expand Up @@ -18,6 +18,12 @@ public class CommitLog : IQueryableCommitLog
private IList<object> excludedIdentifier = new List<object>();
private readonly GitSortOptions sortOptions;

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

/// <summary>
/// Initializes a new instance of the <see cref = "CommitLog" /> class.
/// The commits will be enumerated according in reverse chronological order.
Expand All @@ -42,7 +48,7 @@ internal CommitLog(Repository repo, GitSortOptions sortingStrategy)
/// <summary>
/// Gets the current sorting strategy applied when enumerating the log
/// </summary>
public GitSortOptions SortedBy
public virtual GitSortOptions SortedBy
{
get { return sortOptions; }
}
Expand All @@ -53,7 +59,7 @@ public GitSortOptions SortedBy
/// Returns an enumerator that iterates through the log.
/// </summary>
/// <returns>An <see cref = "IEnumerator{T}" /> object that can be used to iterate through the log.</returns>
public IEnumerator<Commit> GetEnumerator()
public virtual IEnumerator<Commit> GetEnumerator()
{
if ((repo.Info.IsEmpty) && includedIdentifier.Any(o => PointsAtTheHead(o.ToString()))) // TODO: ToString() == fragile
{
Expand All @@ -79,7 +85,7 @@ IEnumerator IEnumerable.GetEnumerator()
/// </summary>
/// <param name = "filter">The options used to control which commits will be returned.</param>
/// <returns>A list of commits, ready to be enumerated.</returns>
public ICommitLog QueryBy(Filter filter)
public virtual ICommitLog QueryBy(Filter filter)
{
Ensure.ArgumentNotNull(filter, "filter");
Ensure.ArgumentNotNull(filter.Since, "filter.Since");
Expand Down Expand Up @@ -130,7 +136,7 @@ private static bool PointsAtTheHead(string shaOrRefName)
/// <param name = "first">The first <see cref = "Commit"/>.</param>
/// <param name = "second">The second <see cref = "Commit"/>.</param>
/// <returns>The common ancestor or null if none found.</returns>
public Commit FindCommonAncestor(Commit first, Commit second)
public virtual Commit FindCommonAncestor(Commit first, Commit second)
{
Ensure.ArgumentNotNull(first, "first");
Ensure.ArgumentNotNull(second, "second");
Expand All @@ -157,7 +163,7 @@ public Commit FindCommonAncestor(Commit first, Commit second)
/// </summary>
/// <param name = "commits">The <see cref = "Commit"/>s for which to find the common ancestor.</param>
/// <returns>The common ancestor or null if none found.</returns>
public Commit FindCommonAncestor(IEnumerable<Commit> commits)
public virtual Commit FindCommonAncestor(IEnumerable<Commit> commits)
{
Ensure.ArgumentNotNull(commits, "commits");
Commit ret = null;
Expand Down

0 comments on commit d62ae53

Please sign in to comment.