public IActionResult Index() { var api = new HackerNewsApi(); List <HackerNews> hn = api.Get20News(); return(View(hn)); }
public void CanNotPassNegativeToTopStories() { HackerNewsApi client = new HackerNewsApi(); IEnumerable <HackerNewsItem> ids = client.TopStories(-1); Assert.IsTrue(ids.Count() == 0); }
public void CanAskForInvalidItem() { HackerNewsApi client = new HackerNewsApi(); HackerNewsItem item = client.NewsItem(int.MaxValue).Result; Assert.IsTrue(item == null); }
public void CanGetMaxTopStories() { HackerNewsApi client = new HackerNewsApi(); IEnumerable <HackerNewsItem> ids = client.TopStories(105); Assert.IsTrue(ids.Count() == 100); }
public void CanGetTopStoryIds() { HackerNewsApi client = new HackerNewsApi(); IEnumerable <int> ids = client.TopStoryIds().Result; Assert.IsTrue(ids.Any()); }
public void CanGetStory() { HackerNewsApi client = new HackerNewsApi(); HackerNewsItem storyItem = client.NewsItem(GOOD_STORY_ID).Result; Assert.IsNotNull(storyItem); }
public void CanGetUserProfile() { HackerNewsApi client = new HackerNewsApi(); HackerNewsUserProfile userProfile = client.UserProfile(GOOD_USER_ID).Result; Assert.IsNotNull(userProfile); }
public void CanGetTopStories() { HackerNewsApi client = new HackerNewsApi(); IEnumerable <HackerNewsItem> ids = client.TopStories(2); Assert.IsTrue(ids.Count() == 2); Assert.IsTrue(ids.ElementAt(0) != null); Assert.IsTrue(ids.ElementAt(1) != null); }
static void Main(string[] args) { var api = new HackerNewsApi(); IEnumerable <HackerNewsItem> stories = api.TopStories(20); foreach (var item in stories) { Console.WriteLine(item.Title + " " + item.Score); } Console.ReadKey(true); }
public ActionResult Index() { var api = new HackerNewsApi(); return(View(api.GetTopStories(20))); }
public void Load() { HackerNewsApi api = new HackerNewsApi(); ErrorMessage = ""; IsLoading = true; api.GetComments(Post.Item_ID, (comments) => { comments = OrderComments(comments); Comments = new BindableCollection<CommentItem>(comments); IsLoading = false; }, (error) => { IsLoading = false; }); }
public MainPage() { InitializeComponent(); _apiClient = new HackerNewsApi(); }
public void Load() { ErrorMessage = ""; Posts.Clear(); IsLoading = true; HackerNewsApi api = new HackerNewsApi(); api.GetPosts(PostType, (posts) => { // last item is a reference to the next page, could fix by specifying a page (or use this with a "more" button) posts.RemoveAt(posts.Count - 1); // used to make the object know how to navigate... // hack foreach (PostItem post in posts) { post.NavigationService = _navigationService; } Posts = new BindableCollection<PostItem>(posts); IsLoading = false; }, (error) => { ErrorMessage = error; IsLoading = false; }); }