本文整理汇总了C#中TeamsClient类的典型用法代码示例。如果您正苦于以下问题:C# TeamsClient类的具体用法?C# TeamsClient怎么用?C# TeamsClient使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TeamsClient类属于命名空间,在下文中一共展示了TeamsClient类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: EnsuresNonNullArguments
public async Task EnsuresNonNullArguments()
{
var teams = new TeamsClient(Substitute.For<IApiConnection>());
await Assert.ThrowsAsync<ArgumentNullException>(() => teams.GetAll(null));
await Assert.ThrowsAsync<ArgumentNullException>(() => teams.GetAll("orgName", null));
}
示例2: RequestsTheCorrectlUrl
public void RequestsTheCorrectlUrl()
{
var connection = Substitute.For<IApiConnection>();
var client = new TeamsClient(connection);
client.Get(1);
connection.Received().Get<Team>(Arg.Is<Uri>(u => u.ToString() == "teams/1"), null);
}
示例3: RequestsTheCorrectUrl
public void RequestsTheCorrectUrl()
{
var connection = Substitute.For<IApiConnection>();
var client = new TeamsClient(connection);
client.GetAll("orgName");
connection.Received().GetAll<Team>(Arg.Is<Uri>(u => u.ToString() == "orgs/orgName/teams"));
}
示例4: EnsuresNonNullArguments
public void EnsuresNonNullArguments()
{
var connection = Substitute.For<IApiConnection>();
var client = new TeamsClient(connection);
var team = new NewTeam("superstars");
Assert.Throws<ArgumentNullException>(() => client.Create(null, team));
Assert.Throws<ArgumentException>(() => client.Create("", team));
Assert.Throws<ArgumentNullException>(() => client.Create("name", null));
}
示例5: RequestsTheCorrectUrl
public void RequestsTheCorrectUrl()
{
var connection = Substitute.For<IApiConnection>();
var client = new TeamsClient(connection);
var team = new UpdateTeam("Octokittens");
client.UpdateTeam(1, team);
connection.Received().Patch<Team>(Arg.Is<Uri>(u => u.ToString() == "teams/1"), team);
}
示例6: EnsuresNonNullArguments
public async Task EnsuresNonNullArguments()
{
var connection = Substitute.For<IApiConnection>();
var client = new TeamsClient(connection);
AssertEx.Throws<ArgumentNullException>(async () => await
client.CreateTeam("", new NewTeam("superstars")));
AssertEx.Throws<ArgumentException>(async () => await
client.CreateTeam("name", null));
}
示例7: EnsuresNonEmptyLogin
public void EnsuresNonEmptyLogin()
{
var connection = Substitute.For<IApiConnection>();
var client = new TeamsClient(connection);
AssertEx.Throws<ArgumentException>(() => client.IsMember(1, ""));
}
示例8: RequestsTheCorrectUrl
public async Task RequestsTheCorrectUrl()
{
var connection = Substitute.For<IApiConnection>();
var client = new TeamsClient(connection);
await client.AddMembership(1, "user");
connection.Received().Put<Dictionary<string, string>>(
Arg.Is<Uri>(u => u.ToString() == "teams/1/memberships/user"),
Args.Object);
}
示例9: RequestsTheCorrectUrl
public void RequestsTheCorrectUrl()
{
var connection = Substitute.For<IApiConnection>();
var client = new TeamsClient(connection);
client.GetAllForCurrent();
connection.Received().GetAll<Team>(
Arg.Is<Uri>(u => u.ToString() == "user/teams"),
Args.ApiOptions);
}
示例10: EnsuresNonNullOrEmptyArguments
public async Task EnsuresNonNullOrEmptyArguments()
{
var connection = Substitute.For<IApiConnection>();
var client = new TeamsClient(connection);
// Check owner arguments.
await Assert.ThrowsAsync<ArgumentNullException>(() => client.RemoveRepository(1, null, "repoName"));
await Assert.ThrowsAsync<ArgumentException>(() => client.RemoveRepository(1, "", "repoName"));
// Check repo arguments.
await Assert.ThrowsAsync<ArgumentNullException>(() => client.RemoveRepository(1, "ownerName", null));
await Assert.ThrowsAsync<ArgumentException>(() => client.RemoveRepository(1, "ownerName", ""));
}
示例11: AddOrUpdatePermission
public void AddOrUpdatePermission()
{
var connection = Substitute.For<IApiConnection>();
var client = new TeamsClient(connection);
var newPermission = new RepositoryPermissionRequest(Permission.Admin);
client.AddRepository(1, "org", "repo", newPermission);
connection.Connection.Received().Put<HttpStatusCode>(Arg.Is<Uri>(u => u.ToString() == "teams/1/repos/org/repo"), Arg.Any<object>(), "", "application/vnd.github.ironman-preview+json");
}
示例12: EnsuresNonNullOrEmptyLogin
public async Task EnsuresNonNullOrEmptyLogin()
{
var connection = Substitute.For<IApiConnection>();
var client = new TeamsClient(connection);
await Assert.ThrowsAsync<ArgumentNullException>(() => client.RemoveMembership(1, null));
await Assert.ThrowsAsync<ArgumentException>(() => client.RemoveMembership(1, ""));
}
示例13: EnsuresNonNullLogin
public void EnsuresNonNullLogin()
{
var connection = Substitute.For<IApiConnection>();
var client = new TeamsClient(connection);
Assert.ThrowsAsync<ArgumentNullException>(() => client.GetMembership(1, null));
}
示例14: AllowsEmptyBody
public async Task AllowsEmptyBody()
{
var connection = Substitute.For<IConnection>();
var apiConnection = new ApiConnection(connection);
var client = new TeamsClient(apiConnection);
await client.AddMembership(1, "user");
connection.Received().Put<Dictionary<string, string>>(
Arg.Is<Uri>(u => u.ToString() == "teams/1/memberships/user"),
Arg.Is<object>(u => u == RequestBody.Empty));
}
示例15: EnsureNonNullOrg
public void EnsureNonNullOrg()
{
var connection = Substitute.For<IApiConnection>();
var client = new TeamsClient(connection);
Assert.ThrowsAsync<ArgumentException>(() => client.AddRepository(1, null, "Repo Name"));
}