Exemplo n.º 1
0
        private void LoadPanel(string header)
        {
            switch (header)
            {
            case "news":
                if (EventsRequest == null)
                {
                    EventsRequest = new UserReceivedEventsRequest(_githubService.Username);
                }
                break;

            case "repositories":
                if (RepositoriesRequest == null)
                {
                    RepositoriesRequest = new RepositoriesRequest();
                }
                break;

            case "followers":
                if (FollowersRequest == null)
                {
                    FollowersRequest = new UserFollowersRequest(_githubService.Username);
                }
                break;

            case "following":
                if (FollowingsRequest == null)
                {
                    FollowingsRequest = new UserFollowingRequest(_githubService.Username);
                }
                break;
            }
        }
Exemplo n.º 2
0
        public void Test_UserFollowersRequest_Returns_Valid_UriPathParameters()
        {
            // without extended info
            var request = new UserFollowersRequest {
                Username = "******"
            };

            request.GetUriPathParameters().Should().NotBeNull()
            .And.HaveCount(1)
            .And.Contain(new Dictionary <string, object>
            {
                ["username"] = "******"
            });

            // with extended info
            var extendedInfo = new TraktExtendedInfo {
                Full = true
            };

            request = new UserFollowersRequest {
                Username = "******", ExtendedInfo = extendedInfo
            };

            request.GetUriPathParameters().Should().NotBeNull()
            .And.HaveCount(2)
            .And.Contain(new Dictionary <string, object>
            {
                ["username"] = "******",
                ["extended"] = extendedInfo.ToString()
            });
        }
Exemplo n.º 3
0
        public void Test_UserFollowersRequest_Validate_Throws_Exceptions()
        {
            // username is null
            var request = new UserFollowersRequest();

            Action act = () => request.Validate();

            act.Should().Throw <ArgumentNullException>();

            // empty username
            request = new UserFollowersRequest {
                Username = string.Empty
            };

            act = () => request.Validate();
            act.Should().Throw <ArgumentException>();

            // username with spaces
            request = new UserFollowersRequest {
                Username = "******"
            };

            act = () => request.Validate();
            act.Should().Throw <ArgumentException>();
        }
Exemplo n.º 4
0
        private void LoadPanel(string header)
        {
            switch (header)
            {
            case "news feed":
                if (EventsRequest == null)
                {
                    EventsRequest = new UserReceivedEventsRequest(_githubService.Username);
                }
                break;

            case "owned repos":
                if (OwnedRepositoriesRequest == null)
                {
                    OwnedRepositoriesRequest = new RepositoriesRequest();
                }
                break;

            case "watched reps":
                if (WatchedRepositoriesRequest == null)
                {
                    WatchedRepositoriesRequest = new RepositoriesWatchedRequest(_githubService.Username);
                }
                break;

            case "follower":
                if (FollowersRequest == null)
                {
                    FollowersRequest = new UserFollowersRequest(_githubService.Username);
                }
                break;

            case "following":
                if (FollowingsRequest == null)
                {
                    FollowingsRequest = new UserFollowingRequest(_githubService.Username);
                }
                break;

            case "profile":
                if (User == null)
                {
                    User = _githubService.Load(new UserRequest(_githubService.Username), u =>
                    {
                        User = u;
                        _githubService.Load(new UserOrganizationRequest(_githubService.Username), organizations =>
                        {
                            foreach (var organization in organizations)
                            {
                                Organizations.Add(organization);
                            }
                        });
                    });
                }
                break;
            }
        }
Exemplo n.º 5
0
        private void OnPivotChanged(GithubService githubService, SelectionChangedEventArgs args)
        {
            var header = ((PivotItem)args.AddedItems[0]).Header as String;

            ShowAppBar = false;
            switch (header)
            {
            case "feed":
                if (EventsRequest == null)
                {
                    EventsRequest = new UserEventsRequests(Username);
                }
                break;

            case "owned repos":
                if (RepositoriesRequest == null)
                {
                    RepositoriesRequest = new RepositoriesRequest(Username);
                }
                break;

            case "watched reps":
                if (RepositoriesWatchedRequest == null)
                {
                    RepositoriesWatchedRequest = new RepositoriesWatchedRequest(Username);
                }
                break;

            case "follower":
                if (FollowersRequest == null)
                {
                    FollowersRequest = new UserFollowersRequest(Username);
                }
                break;

            case "following":
                if (FollowingsRequest == null)
                {
                    FollowingsRequest = new UserFollowingRequest(Username);
                }
                break;

            case "profile":
            case "details":
                if (User == null)
                {
                    User = githubService.Load(new UserRequest(Username), u => User = u);
                    if (githubService.IsAuthenticated)
                    {
                        IsFollowing = githubService.Load(new FollowUserRequest(Username), r => { IsFollowing = r; });
                    }
                }
                ShowAppBar = true;
                break;
            }
        }
Exemplo n.º 6
0
        private void LoadPanel(string header)
        {
            switch (header)
            {
            case "news feed":
                if (EventsRequest == null)
                {
                    EventsRequest = new UserReceivedEventsRequest(_githubService.Username);
                }
                break;

            case "owned repos":
                if (OwnedRepositoriesRequest == null)
                {
                    OwnedRepositoriesRequest = new RepositoriesRequest();
                }
                break;

            case "watched reps":
                if (WatchedRepositoriesRequest == null)
                {
                    WatchedRepositoriesRequest = new RepositoriesWatchedRequest(_githubService.Username);
                }
                break;

            case "follower":
                if (FollowersRequest == null)
                {
                    FollowersRequest = new UserFollowersRequest(_githubService.Username);
                }
                break;

            case "following":
                if (FollowingsRequest == null)
                {
                    FollowingsRequest = new UserFollowingRequest(_githubService.Username);
                }
                break;

            case "profile":
                if (User == null)
                {
                    User = _githubService.Load(new UserRequest(_githubService.Username), u => User = u);
                }
                break;
            }
        }
Exemplo n.º 7
0
 private void LoadPanel(string header)
 {
     switch (header)
     {
         case "news":
             if (EventsRequest == null)
                 EventsRequest = new UserReceivedEventsRequest(_githubService.Username);
             break;
         case "repositories":
             if (RepositoriesRequest == null)
                 RepositoriesRequest = new RepositoriesRequest();
             break;
         case "followers":
             if (FollowersRequest == null)
                 FollowersRequest = new UserFollowersRequest(_githubService.Username);
             break;
         case "following":
             if (FollowingsRequest == null)
                 FollowingsRequest = new UserFollowingRequest(_githubService.Username);
             break;
     }
 }
Exemplo n.º 8
0
 private void OnPivotChanged(GithubService githubService, SelectionChangedEventArgs args)
 {
     var header = ((PivotItem)args.AddedItems[0]).Header as String;
     ShowAppBar = false;
     switch (header)
     {
         case "feed":
             if (EventsRequest == null)
                 EventsRequest = new UserEventsRequests(Username);
             break;
         case "owned repos":
             if (RepositoriesRequest == null)
                 RepositoriesRequest = new RepositoriesRequest(Username);
             break;
         case "watched reps":
             if (RepositoriesWatchedRequest == null)
                 RepositoriesWatchedRequest = new RepositoriesWatchedRequest(Username);
             break;
         case "follower":
             if (FollowersRequest == null)
                 FollowersRequest = new UserFollowersRequest(Username);
             break;
         case "following":
             if (FollowingsRequest == null)
                 FollowingsRequest = new UserFollowingRequest(Username);
             break;
         case "profile":
         case "details":
             if (User == null)
             {
                 User = githubService.Load(new UserRequest(Username), u => User = u);
                 if (githubService.IsAuthenticated)
                     IsFollowing = githubService.Load(new FollowUserRequest(Username), r => { IsFollowing = r; });
             }
             ShowAppBar = true;
             break;
     }
 }
Exemplo n.º 9
0
        public void Test_UserFollowersRequest_Has_Valid_UriTemplate()
        {
            var request = new UserFollowersRequest();

            request.UriTemplate.Should().Be("users/{username}/followers{?extended}");
        }
Exemplo n.º 10
0
        public void Test_UserFollowersRequest_Has_AuthorizationRequirement_Optional()
        {
            var request = new UserFollowersRequest();

            request.AuthorizationRequirement.Should().Be(AuthorizationRequirement.Optional);
        }
Exemplo n.º 11
0
 private void LoadPanel(string header)
 {
     switch (header)
     {
         case "news feed":
             if (EventsRequest == null)
                 EventsRequest = new UserReceivedEventsRequest(_githubService.Username);
             break;
         case "owned repos":
             if (OwnedRepositoriesRequest == null)
                 OwnedRepositoriesRequest = new RepositoriesRequest();
             break;
         case "watched reps":
         if (WatchedRepositoriesRequest == null)
             WatchedRepositoriesRequest = new RepositoriesWatchedRequest(_githubService.Username);
         break;
         case "follower":
             if (FollowersRequest == null)
                 FollowersRequest = new UserFollowersRequest(_githubService.Username);
             break;
         case "following":
             if (FollowingsRequest == null)
                 FollowingsRequest = new UserFollowingRequest(_githubService.Username);
             break;
         case "profile":
             if (User == null)
                 User = _githubService.Load(new UserRequest(_githubService.Username), u =>
                 {
                     User = u;
                     _githubService.Load(new UserOrganizationRequest(_githubService.Username), organizations =>
                     {
                         foreach (var organization in organizations)
                             Organizations.Add(organization);
                     });
                 });
             break;
     }
 }