示例#1
0
        public BookData FindBookById(string id)
        {
            if (string.IsNullOrEmpty(id))
            {
                throw new ArgumentNullException("id");
            }
            BookData book = new BookData();
            var getUri = baseUrl + @"/" + id;

            using (var webClient = new GZipWebClient())
            {
                book = JsonConvert.DeserializeObject<BookData>(webClient.DownloadString(getUri));
            }

            return book;
        }
示例#2
0
        public BookData FindBookByIsbn(string isbn)
        {
            if (string.IsNullOrEmpty(isbn))
            {
                throw new ArgumentNullException("isbn");
            }
            BookData book = new BookData();
            var getUri = searchBaseUrl + "isbn:" + isbn;

            using (var webClient = new GZipWebClient())
            {
                var books = JsonConvert.DeserializeObject<BooksData>(webClient.DownloadString(getUri));
                if (books.TotalItems == 1)
                {
                    book = books.Items[0];
                }
            }

            return book;
        }
        public void Setup()
        {
            detailsMock = new Mock<IDetails>();

            bookTest = new BookData
            {
                Id = "AuMpAQAAMAA",
                VolumeInfo = new VolumeInfo
                {
                    Title = "WebApi Introdutcion",
                    SubTitle = "For Dummy",
                    Authors = new List<string>() { "Microsoft" }
                }
            };
        }