mirror of
https://github.com/zoriya/octokit.net.git
synced 2026-06-03 11:05:56 +00:00
RepositoryContext class and Extension methods
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Octokit.Tests.Integration.Helpers
|
||||
{
|
||||
internal static class GithubClientExtensions
|
||||
{
|
||||
internal async static Task<RepositoryContext> CreateRepositoryContext(this IGitHubClient client, string repositoryName)
|
||||
{
|
||||
var repoName = Helper.MakeNameWithTimestamp(repositoryName);
|
||||
var repo = await client.Repository.Create(new NewRepository(repoName) { AutoInit = true });
|
||||
|
||||
return new RepositoryContext(repo);
|
||||
}
|
||||
|
||||
internal async static Task<RepositoryContext> CreateRepositoryContext(this IGitHubClient client, string organizationLogin, NewRepository newRepository)
|
||||
{
|
||||
var repo = await client.Repository.Create(organizationLogin, newRepository);
|
||||
|
||||
return new RepositoryContext(repo);
|
||||
}
|
||||
|
||||
internal async static Task<RepositoryContext> CreateRepositoryContext(this IGitHubClient client, NewRepository newRepository)
|
||||
{
|
||||
var repo = await client.Repository.Create(newRepository);
|
||||
|
||||
return new RepositoryContext(repo);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Octokit.Tests.Integration.Helpers
|
||||
{
|
||||
internal sealed class RepositoryContext : IDisposable
|
||||
{
|
||||
internal RepositoryContext(Repository repo)
|
||||
{
|
||||
Repository = repo;
|
||||
}
|
||||
|
||||
internal Repository Repository { get; private set; }
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Helper.DeleteRepo(Repository);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -102,8 +102,10 @@
|
||||
<Compile Include="fixtures\RepositoriesHooksCollection.cs" />
|
||||
<Compile Include="fixtures\RepositoriesHooksFixture.cs" />
|
||||
<Compile Include="Helpers\ApplicationTestAttribute.cs" />
|
||||
<Compile Include="Helpers\GithubClientExtensions.cs" />
|
||||
<Compile Include="Helpers\PersonalAccessTokenTestAttribute.cs" />
|
||||
<Compile Include="Helpers\PaidAccountTestAttribute.cs" />
|
||||
<Compile Include="Helpers\RepositoryContext.cs" />
|
||||
<Compile Include="Helpers\RepositorySetupHelper.cs" />
|
||||
<Compile Include="HttpClientAdapterTests.cs" />
|
||||
<Compile Include="Clients\TeamsClientTests.cs" />
|
||||
|
||||
Reference in New Issue
Block a user