Esempio n. 1
0
        public void SingleImageSave()
        {
            long newsId    = 32434321;
            var  HDURL     = string.Empty;
            var  NormalURL = string.Empty;
            var  image     = new TouTiaoImageInfo()
            {
                Height  = 200,
                Width   = 150,
                UrlList = new List <string>()
                {
                    "http://p0.pstatp.com/origin/252/6926772543"
                }
            };

            dataService.SingleImageSave(image, newsId, out HDURL, out NormalURL);
        }
Esempio n. 2
0
        public void SingleImageSave(TouTiaoImageInfo imageInfo, long newsId, out string HDURL, out string NormalURL)
        {
            HDURL = NormalURL = string.Empty;
            if (imageInfo.UrlList != null && imageInfo.UrlList.Count > 0)
            {
                //download single one from any one url
                var single_img_url = imageInfo.UrlList[0];
                MakeSureDIRExist(NEWS_IMAGE_DIR_BASE);
                MakeSureDIRExist(NEWS_DEST_HD_IMAGE_DIR_BASE);
                MakeSureDIRExist(NEWS_DEST_NORMAL_IMAGE_DIR_BASE);
                var fileNamePath = HttpHelper.DownloadFile(single_img_url, Path.Combine(NEWS_IMAGE_DIR_BASE, GetFileNameFromURL(single_img_url)));

                var destFileNameHD     = ImageHelper.ResizedHD(fileNamePath, NEWS_DEST_HD_IMAGE_DIR_BASE, newsId);
                var destFileNameNormal = ImageHelper.ResizedNormal(fileNamePath, NEWS_DEST_NORMAL_IMAGE_DIR_BASE, newsId);
                HDURL     = destFileNameHD;
                NormalURL = destFileNameNormal;
            }
        }
Esempio n. 3
0
        public void AnlynazeTest()
        {
            var resonse       = GetMockResponse();
            var toutiaoResult = dataService.DeserializeTouTiao(resonse);

            long cursor   = 0;
            var  instance = dataService.Anlynaze(toutiaoResult, out cursor);

            #region Expect value

            var image1 = new TouTiaoImageInfo()
            {
                Width   = 410,
                Height  = 283,
                UrlList = new List <string>()
                {
                    "http://p0.pstatp.com/origin/252/5327833163",
                    "http://p.pstatp.com/origin/252/5327833163"
                },
            };

            var image2 = new TouTiaoImageInfo()
            {
            };

            var content1 = new TouTiaoContent()
            {
                AppOpeURL   = "snssdk143://detail?groupid=2385553034",
                PublishTime = (long)1377039960.0,
                NewsId      = 2385553034,
                Title       = "4\u540d\u5fd7",
                ImageList   = new List <TouTiaoImageInfo>()
                {
                    image1, image2
                },
            };

            var content2 = new TouTiaoContent()
            {
                NewsId        = 2348076531,
                FavoriteCount = 19,
                GroupId       = 2348076531
            };

            var expect_cur = new TouTiaoCursor()
            {
                Cursor      = 1376933340,
                ContentList = new List <TouTiaoContent>()
                {
                    content1, content2
                }
            };
            var expect_ret = new TouTiaoResult()
            {
                ret          = 0,
                Msg          = "OK",
                DataByCursor = expect_cur
            };

            #endregion

            Assert.Equal(cursor, 1376933340);
            Assert.Equal(instance.Count, 2);
            Assert.Equal(true, expect_cur.ContentList.Any(x => x.NewsId == instance[0].NewsId));
        }