public ObservableEnterpriseLdapClientTests()
        {
            _github = new ObservableGitHubClient(EnterpriseHelper.GetAuthenticatedClient());

            NewTeam newTeam = new NewTeam(Helper.MakeNameWithTimestamp("test-team")) { Description = "Test Team" };
            _context = _github.CreateEnterpriseTeamContext(EnterpriseHelper.Organization, newTeam).Result;
        }
            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));
            }
            public void RequestsTheCorrectUrl()
            {
                var connection = Substitute.For<IApiConnection>();
                var client = new TeamsClient(connection);
                var team = new NewTeam("Octokittens");

                client.Create("orgName", team);

                connection.Received().Post<Team>(Arg.Is<Uri>(u => u.ToString() == "orgs/orgName/teams"), team);
            }
            public void PostsToCorrectUrl()
            {
                var team = new NewTeam("avengers");
                var github = Substitute.For<IGitHubClient>();
                var client = new ObservableTeamsClient(github);

                client.Create("shield", team);

                github.Organization.Team.Received().Create("shield", team);
            }
Пример #5
0
            public async Task EnsuresNonNullArguments()
            {
                var connection = Substitute.For <IApiConnection>();
                var client     = new TeamsClient(connection);
                var team       = new NewTeam("superstars");

                await Assert.ThrowsAsync <ArgumentNullException>(() => client.Create(null, team));

                await Assert.ThrowsAsync <ArgumentException>(() => client.Create("", team));

                await Assert.ThrowsAsync <ArgumentNullException>(() => client.Create("name", null));
            }
Пример #6
0
        public async Task SucceedsWhenAuthenticated()
        {
            var github = new GitHubClient(new ProductHeaderValue("OctokitTests"))
            {
                Credentials = Helper.Credentials
            };

            var newTeam = new NewTeam(Guid.NewGuid().ToString());

            var team = await github.Organization.Team.Create(Helper.Organization, newTeam);

            Assert.Equal(newTeam.Name, team.Name);
        }
Пример #7
0
        public async Task FailsWhenAuthenticatedWithBadCredentials()
        {
            var github = new GitHubClient(new ProductHeaderValue("OctokitTests"))
            {
                Credentials = new Credentials(Helper.Credentials.Login, "bad-password")
            };
            var newTeam = new NewTeam("Test");

            var e = await AssertEx.Throws <AuthorizationException>(async
                                                                       () => await github.Organization.Team.Create(Helper.Organization, newTeam));

            Assert.Equal(HttpStatusCode.Unauthorized, e.StatusCode);
        }
Пример #8
0
            public void RequestsTheCorrectUrl()
            {
                var connection = Substitute.For <IApiConnection>();
                var client     = new TeamsClient(connection);
                var team       = new NewTeam("Octokittens");

                client.Create("orgName", team);

                connection.Received().Post <Team>(
                    Arg.Is <Uri>(u => u.ToString() == "orgs/orgName/teams"),
                    team,
                    "application/vnd.github.hellcat-preview+json");
            }
Пример #9
0
        public object Create([FromBody] NewTeam team)
        {
            if (team == null)
            {
                return(StatusCode(500));
            }
            var newTeam = new Team()
            {
                Name = team.Name, Phone = team.Phone
            };

            _context.Teams.Add(newTeam);
            if (_context.SaveChanges() != 0)
            {
                return(StatusCode(201, TeamService.GetTeam(_context.Teams.Find(newTeam.TeamId))));
            }
            else
            {
                return(StatusCode(404));
            }
        }
 /// <summary>
 /// Returns newly created <see cref="Team" /> for the current org.
 /// </summary>
 /// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
 /// <returns>Newly created <see cref="Team"/></returns>
 public IObservable<Team> CreateTeam(string org, NewTeam team)
 {
     return _client.CreateTeam(org, team).ToObservable();
 }
Пример #11
0
        internal static async Task <TeamContext> CreateTeamContext(this IGitHubClient client, string organization, NewTeam newTeam)
        {
            newTeam.Privacy = TeamPrivacy.Closed;
            var team = await client.Organization.Team.Create(organization, newTeam);

            return(new TeamContext(client.Connection, team));
        }
        /// <summary>
        /// Returns newly created <see cref="Team" /> for the current org.
        /// </summary>
        /// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
        /// <returns>Newly created <see cref="Team"/></returns>
        public IObservable<Team> Create(string org, NewTeam team)
        {
            Ensure.ArgumentNotNullOrEmptyString(org, "org");
            Ensure.ArgumentNotNull(team, "team");

            return _client.Create(org, team).ToObservable();
        }
        internal static async Task <TeamContext> CreateEnterpriseTeamContext(this IObservableGitHubClient client, string organization, NewTeam newTeam)
        {
            var team = await client.Organization.Team.Create(organization, newTeam);

            return(new TeamContext(client.Connection, team));
        }
 /// <summary>
 /// Returns newly created <see cref="Team" /> for the current org.
 /// </summary>
 /// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
 /// <returns>Newly created <see cref="Team"/></returns>
 public IObservable <Team> CreateTeam(string org, NewTeam team)
 {
     return(_client.CreateTeam(org, team).ToObservable());
 }
Пример #15
0
        internal async static Task <EnterpriseTeamContext> CreateEnterpriseTeamContext(this IGitHubClient client, string organization, NewTeam newTeam)
        {
            var team = await client.Organization.Team.Create(organization, newTeam);

            return(new EnterpriseTeamContext(team));
        }
        internal static async Task<TeamContext> CreateEnterpriseTeamContext(this IObservableGitHubClient client, string organization, NewTeam newTeam)
        {
            var team = await client.Organization.Team.Create(organization, newTeam);

            return new TeamContext(client.Connection, team);
        }