public void ShouldMapFakeDTOsTogether()
        {
            var productDTOs = new List<ProductDTO>();

            for (var i = 0; i < 10; i++)
            {
                var productDTO = new ProductDTO {ASIN = i.ToString()};

                productDTOs.Add(productDTO);
            }

            var reviewDTOs = new List<ReviewDTO>();
            for (int i = 5; i < 15; i++)
            {
                var reviewDTO = new ReviewDTO {ASIN = i.ToString()};

                reviewDTOs.Add(reviewDTO);
            }

            var amazonRequest = new AmazonRequest();

            reviewMapper = new ReviewListMapper(amazonRequest, reviewDTOs, productDTOs);

            var reviews = reviewMapper.GetReviewList();

            Assert.AreNotEqual(0, reviews.Count);
            Debug.WriteLine(reviews.Count);
        }
        public void ShouldReturnAuthors()
        {
            string[] authors = { "Martin Fowler", "Kent Beck", "John Brant", "William Opdyke", "Don Roberts" };

            string authorsFlattened = new ProductDTO {Authors = authors}.Authors();

            Assert.IsFalse(string.IsNullOrEmpty(authorsFlattened));
            Assert.AreEqual("Martin Fowler, Kent Beck, John Brant, William Opdyke, Don Roberts", authorsFlattened);
            Debug.WriteLine(authorsFlattened);
        }
        public void ShouldSortAuthorsByMLA()
        {
            string[] authors = {"Martin Fowler", "Kent Beck", "John Brant", "William Opdyke", "Don Roberts"};

            var authorsInMLA = new ProductDTO {Authors = authors}.AuthorsInMlaFormat();

            Assert.IsFalse(string.IsNullOrEmpty(authorsInMLA));
            Assert.AreEqual("Fowler Martin, et al.", authorsInMLA);
            Debug.WriteLine(authorsInMLA);

            string[] edgeCaseAuthors = { "Daniel P. Friedman", "William E. Byrd", "Oleg Kiselyov" };
            authorsInMLA = new ProductDTO {Authors = edgeCaseAuthors}.AuthorsInMlaFormat();

            Assert.AreEqual("Friedman P. Daniel, Byrd E. William, and Kiselyov Oleg.", authorsInMLA);
            Debug.WriteLine(authorsInMLA);

            string[] fewAuthors = { "Daniel P. Friedman", "William E. Byrd" };
            authorsInMLA = new ProductDTO {Authors = fewAuthors}.AuthorsInMlaFormat();

            Assert.AreEqual("Friedman P. Daniel, and Byrd E. William.", authorsInMLA);
            Debug.WriteLine(authorsInMLA);
        }
Ejemplo n.º 4
0
        private ProductDTO MapProduct(Item productItem)
        {
            var productToReturn = new ProductDTO
                                      {
                                          ASIN = productItem.ASIN,
                                          Title = productItem.ItemAttributes.Title,
                                          Authors = productItem.ItemAttributes.Author,
                                          Url = productItem.DetailPageURL,
                                          Publisher = productItem.ItemAttributes.Manufacturer
                                      };

            return productToReturn;
        }