コード例 #1
0
        public void TestName()
        {
            //Given
            Deal deal = new DealBuilder()
                        .Name("TEST")
                        .Build();

            //When

            Assert.Equal("TEST", deal.Name);
            //Then
        }
コード例 #2
0
        public static Deal parseRssItem(XmlNode item)
        {
            string title       = item.SelectSingleNode("title").InnerText;
            string description = Parser.removeHTMLElementFromRSS(item.SelectSingleNode("description").InnerText);
            string link        = item.SelectSingleNode("link").InnerText;
            string category    = item.SelectSingleNode("category").InnerText;
            string directLink  = getDirectLink(link);
            string datePosted  = item.SelectSingleNode("pubDate").InnerText;
            string merchantName;
            string price;

            // need to fix this as not all return nulls
            try{
                var merchantInfo = item["pepper:merchant"].Attributes;


                merchantName = merchantInfo["name"].Value;

                price = merchantInfo["price"].Value;

                description = description.Replace(price + " -", "");
            }
            catch (NullReferenceException e)
            {
                merchantName = "None";
                price        = "None";

                Console.WriteLine($"{nameof(e)} Does not exist ");
            }


            string imageLink = item["media:content"].Attributes["url"].Value;


            Deal deal = new DealBuilder()
                        .Name(title)
                        .Price(price)
                        .Category(category)
                        .Link(link)
                        .Description(description)
                        .ImageLink(imageLink)
                        .MerchantName(merchantName)
                        .DirectLink(directLink)
                        .PostedDate(datePosted)
                        .Build();



            return(deal);
        }
コード例 #3
0
        public void RssFeedCount()
        {
            Hotukdeals hotukdeals = hotUKDealRss.Hotukdeal();


            int totalDeal = hotukdeals.Total;

            Assert.Equal(20, totalDeal);

            Deal deal = new DealBuilder()
                        .Name("UnitTest")
                        .Build();

            hotukdeals.addDeal(deal);

            totalDeal = hotukdeals.Total;

            Assert.Equal(21, totalDeal);
        }