catch the failure when disposing of repositories

This commit is contained in:
Brendan Forster
2014-09-29 21:27:45 +10:00
parent 36b9397484
commit 2e225dfcc0
@@ -308,22 +308,34 @@ public class RepositoriesClientTests
Assert.NotNull(thrown);
}
// Clean up the repos.
public void Dispose()
{
var github = new GitHubClient(new ProductHeaderValue("OctokitTests"))
{
Credentials = Helper.Credentials
};
var repositories = github.Repository.GetAllForCurrent().Result;
foreach (var repository in repositories)
try
{
try
// clean all the repositories for the current user
var repositories = github.Repository.GetAllForCurrent().Result;
foreach (var repository in repositories.Where(x => x.Owner.Login == Helper.Credentials.Login))
{
github.Repository.Delete(repository.Owner.Login, repository.Name).Wait();
try
{
// only cleanup repositories the current user owns
github.Repository.Delete(repository.Owner.Login, repository.Name).Wait();
}
catch (Exception)
{
}
}
catch (Exception) { }
}
catch (Exception ex)
{
Console.WriteLine("An unexpected exception occurred while retrieving repositories for the current user: " + ex);
}
}
}