Skip to content

Commit 1040c5e

Browse files
yorahnulltoken
authored andcommitted
Make RemoteCollection mockable
1 parent 9ee340f commit 1040c5e

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

LibGit2Sharp/RemoteCollection.cs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@ public class RemoteCollection : IEnumerable<Remote>
1414
{
1515
private readonly Repository repository;
1616

17+
/// <summary>
18+
/// Needed for mocking purposes.
19+
/// </summary>
20+
protected RemoteCollection()
21+
{ }
22+
1723
internal RemoteCollection(Repository repository)
1824
{
1925
this.repository = repository;
@@ -24,7 +30,7 @@ internal RemoteCollection(Repository repository)
2430
/// </summary>
2531
/// <param name = "name">The name of the remote to retrieve.</param>
2632
/// <returns>The retrived <see cref = "Remote" /> if it has been found, null otherwise.</returns>
27-
public Remote this[string name]
33+
public virtual Remote this[string name]
2834
{
2935
get { return RemoteForName(name); }
3036
}
@@ -57,7 +63,7 @@ private Remote RemoteForName(string name)
5763
/// Returns an enumerator that iterates through the collection.
5864
/// </summary>
5965
/// <returns>An <see cref = "IEnumerator{T}" /> object that can be used to iterate through the collection.</returns>
60-
public IEnumerator<Remote> GetEnumerator()
66+
public virtual IEnumerator<Remote> GetEnumerator()
6167
{
6268
return Libgit2UnsafeHelper
6369
.ListAllRemoteNames(repository.Handle)
@@ -83,7 +89,7 @@ IEnumerator IEnumerable.GetEnumerator()
8389
/// <param name = "name">The name of the remote to create.</param>
8490
/// <param name = "url">The location of the repository.</param>
8591
/// <returns>A new <see cref = "Remote" />.</returns>
86-
public Remote Add(string name, string url)
92+
public virtual Remote Add(string name, string url)
8793
{
8894
string fetchRefSpec = string.Format("+refs/heads/*:refs/remotes/{0}/*", name);
8995

@@ -112,7 +118,7 @@ public Remote Create(string name, string url)
112118
/// <param name = "url">The location of the repository.</param>
113119
/// <param name = "fetchRefSpec">The refSpec to be used when fetching from this remote..</param>
114120
/// <returns>A new <see cref = "Remote" />.</returns>
115-
public Remote Add(string name, string url, string fetchRefSpec)
121+
public virtual Remote Add(string name, string url, string fetchRefSpec)
116122
{
117123
Ensure.ArgumentNotNull(name, "name");
118124
Ensure.ArgumentNotNull(url, "url");

0 commit comments

Comments
 (0)