public async Task DemoRun_GetUserPostsAsync(PostsPlatform platform, string userId) { //Arrange PostsClient client = new PostsClient(); //Act var result = await client.GetUserPostsAsync(platform, userId); //Assert Assert.NotNull(result); }
static void Main(string[] args) { try { string allPostsURL = "https://api.posts/posts/all"; string singlePostURL = "https://api.posts/posts/1"; List <Post> allPosts = PostsClient.GetAll(allPostsURL); Console.WriteLine("-------------- GET ALL POSTS ------------------"); allPosts.ForEach(post => Console.WriteLine(post.Title)); Console.WriteLine("-------------- GET SINGLE POST ------------------"); Post firstPost = PostsClient.GetPost(singlePostURL); Console.WriteLine(firstPost.Title); } catch (BadRequestException ex) { Console.ForegroundColor = ConsoleColor.DarkRed; Console.WriteLine($"Message: {ex.Message} | StatusCode: {ex.StatusCode}"); } catch (NotFoundException ex) { Console.ForegroundColor = ConsoleColor.DarkGreen; Console.WriteLine($"Message: {ex.Message} | StatusCode: {ex.StatusCode}"); } catch (Exception ex) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine(ex.Message); } finally { Console.ResetColor(); Console.WriteLine("Press any key to close the app !"); Console.ReadLine(); } }
public PostsController(PostsClient postsClient) { _postsClient = postsClient; }
public PostsClient_GetAllPosts() { _restClientMock = new Mock <IRestClient>(); _postsClient = new PostsClient(_restClientMock.Object); }