Example #1
0
        public void GetAllPosts()
        {
            Console.WriteLine("GetAllPosts start");

            //JsonPlaceHolder could be injected in order to avoid this manual instantiation
            IJsonPlaceHolder client = new JsonPlaceHolder();

            Post[] posts = client.GetPostsAsync().Result;

            Console.WriteLine($"{posts.Length} posts found");

            foreach (var item in posts)
            {
                Console.WriteLine(item);
            }

            Console.WriteLine("GetAllPosts finish");
        }
Example #2
0
        public void GetPostsWithFilter()
        {
            Console.WriteLine("GetPostsWithFilter start");

            //JsonPlaceHolder could be injected in order to avoid this manual instantiation
            IJsonPlaceHolder client = new JsonPlaceHolder();

            IFilterBuilder filterBuilder = new FilterBuilder <Post>();

            filterBuilder.AddParameter("userId", "5");
            filterBuilder.AddParameter("id", "41");

            Post[] posts = client.GetPostsAsync(filterBuilder.Build()).Result;

            Console.WriteLine($"{posts.Length} posts found");

            foreach (var item in posts)
            {
                Console.WriteLine(item);
            }

            Console.WriteLine("GetPostsWithFilter finish");
        }