public void BaseSetup() { _mocks = new MockRepository(); _repo = _mocks.DynamicMock <IRssFeedRepository>(); _feedService = new RssFeedService(_repo); SetUp(); }
public RssStopCommand( TelegramService telegramService, RssFeedService rssFeedService ) { _rssFeedService = rssFeedService; _telegramService = telegramService; }
public SetRssCommand( TelegramService telegramService, RssService rssService, RssFeedService rssFeedService ) { _telegramService = telegramService; _rssService = rssService; _rssFeedService = rssFeedService; }
public DelRssCommand( RssService rssService, RssFeedService rssFeedService, TelegramService telegramService ) { _rssService = rssService; _rssFeedService = rssFeedService; _telegramService = telegramService; }
public RssCtlCallback( TelegramService telegramService, MessageHistoryService messageHistoryService, RssFeedService rssFeedService, RssService rssService ) { _telegramService = telegramService; _messageHistoryService = messageHistoryService; _rssFeedService = rssFeedService; _rssService = rssService; }
private void Initialize(string path, int blogid) { var x = new XmlDocument(); x.Load(path); string username = x.SelectSingleNode("//WordPress/Username").InnerText; string password = x.SelectSingleNode("//WordPress/Password").InnerText; string site = x.SelectSingleNode("//WordPress/Site").InnerText; string feedUrl = x.SelectSingleNode("//Feed/Url").InnerText; readerService = new ReadabilityService(path); rssFeed = new RssFeedService(feedUrl); wpClient = new WordPress(username, password, site, blogid); }
public async void Test1() { var service = new RssFeedService(); var feeds = await RssFeedService.Load("https://habrahabr.ru/rss/hubs/all"); try { Console.WriteLine(feeds[1]); Assert.NotNull(feeds[0]); } catch (Exception e) { Console.Write("You f****d up. No feeds available"); } }
public void ParseInvalidRssFeed_ShouldThrow() { var feedMock = new SyndicationFeed { Title = new TextSyndicationContent("test", TextSyndicationContentKind.Plaintext), BaseUri = new Uri("//testUri.com") }; feedMock.Items = new List <SyndicationItem> { mockSyndicationItem("title", "audio/mpeg", "incorrectInput", "//episodeuri.test.com", 111111) }; _rssFeedRepo.Setup(x => x.CallRssFeed("test")).Returns(feedMock); var service = new RssFeedService(_rssFeedRepo.Object); Assert.Throws <InvalidOperationException>(() => { service.GetRssFeed("test"); }); }
public async Task ParseInvalidRssFeed_ShouldThrow() { var feedMock = new SyndicationFeed { Title = new TextSyndicationContent("test", TextSyndicationContentKind.Plaintext), BaseUri = new Uri("//testUri.com") }; feedMock.Items = new List <SyndicationItem> { MockSyndicationItem("TestEpiId1", "title", "audio/mpeg", "incorrectInput", "http://test.com/test1.mp3", "http://test.com/test1"), }; feedMock.ElementExtensions.Add(new SyndicationElementExtension("showId", "", "testShowId")); _rssFeedRepo.Setup(x => x.CallRssFeed("test")).Returns(feedMock); var service = new RssFeedService(_rssFeedRepo.Object, _fileRepository.Object); var result = await service.ParseRssFeedAsync("test"); Assert.Null(result[0].Url); }
public void ParseValidRssFeed_ShouldReturnValidObject() { var feedMock = new SyndicationFeed { Title = new TextSyndicationContent("test", TextSyndicationContentKind.Plaintext), BaseUri = new Uri("//testUri.com") }; feedMock.Items = new List <SyndicationItem> { mockSyndicationItem("title", "audio/mpeg", "alternate", "//episodeuri.test.com", 111111), mockSyndicationItem("title", "audio/mpeg", "alternate", "//episodeuri.test.com", 222222), mockSyndicationItem("title", "audio/mpeg", "alternate", "//episodeuri.test.com", 333333), mockSyndicationItem("title", "audio/mpeg", "alternate", "//episodeuri.test.com", 444444) }; _rssFeedRepo.Setup(x => x.CallRssFeed("test")).Returns(feedMock); var service = new RssFeedService(_rssFeedRepo.Object); var result = service.GetRssFeed("test"); Assert.NotNull(result[0].Url); Assert.NotNull(result[1].Url); Assert.NotNull(result[2].Url); Assert.NotNull(result[3].Url); }
public async Task ParseValidRssFeed_ShouldReturnValidObject() { var feedMock = new SyndicationFeed { Id = "testShowId", Title = new TextSyndicationContent("test", TextSyndicationContentKind.Plaintext), BaseUri = new Uri("//testUri.com"), Items = new List <SyndicationItem> { MockSyndicationItem("TestEpiId1", "title", "audio/mpeg", "alternate", "http://test.com/test1.mp3", "http://test.com/test1"), MockSyndicationItem("TestEpiId2", "title", "audio/mpeg", "alternate", "http://test.com/test2.mp3", "http://test.com/test2"), } }; _rssFeedRepo.Setup(x => x.CallRssFeed("test")).Returns(feedMock); var service = new RssFeedService(_rssFeedRepo.Object, _fileRepository.Object); var result = await service.ParseRssFeedAsync("test"); Assert.NotNull(result[0].CheckSum); Assert.NotNull(result[1].CheckSum); }
public FeedViewComponent(RssFeedService feedService) { this.feedService = feedService; }
static void ImportWeiboUserData() { DataTable tb = ExcelHelper.ReadExcelToDataTable(@"D:\临时\WeiboUsers.xlsx"); var service = new RssFeedService(ConnectionString, DatabaseName); var cityService = new CityService(ConnectionString, DatabaseName); var userService = new WeiboUserService(ConnectionString, DatabaseName); List <DataRow> rows = new List <DataRow>(); DataTable filtedDt = tb.Clone(); filtedDt.Clear(); foreach (DataRow row in tb.Rows) { string vipStyle = row["官方认证样式"]?.ToString(); if (string.IsNullOrEmpty(vipStyle) || !vipStyle.Contains("icon-vip-b")) { continue; } string name = row["名称"]?.ToString(); if (string.IsNullOrEmpty(name)) { continue; } if (WeiboNameKeywords.Any(k => name.IndexOf(k, StringComparison.OrdinalIgnoreCase) >= 0)) { filtedDt.ImportRow(row); } else { continue; } WeiboUser user = new WeiboUser() { Name = name, Url = row["微博地址"]?.ToString(), Address = row["省"]?.ToString(), Description = row["描述"]?.ToString(), Followers = row["粉丝"]?.ToString(), PublishCount = row["微博数"]?.ToString(), Tags = row["标签"]?.ToString(), Summary = row["简介"]?.ToString(), UpdateTime = DateTime.Now }; if (string.IsNullOrEmpty(user.Address) && string.IsNullOrEmpty(user.Description)) { continue; } string province = Provinces.FirstOrDefault(k => user.Description.IndexOf(k, StringComparison.OrdinalIgnoreCase) >= 0); string city = ""; if (!string.IsNullOrEmpty(user.Address)) { var cityData = cityService.GetLikeCityName(user.Address); if (cityData != null) { city = cityData.City; if (province == null) { province = cityData.Province; } } } if (string.IsNullOrEmpty(province) && string.IsNullOrEmpty(city)) { continue; } user.Province = province; user.City = city; userService.Create(user); } }
/// <summary> /// Initializes a new instance of the <see cref="FeedController"/> class. /// </summary> /// <param name="rssFeedService">RssFeedService.</param> /// <param name="presentationService">PresentationService.</param> public FeedController(RssFeedService rssFeedService, PresentationService presentationService) { this.feedService = rssFeedService ?? throw new ArgumentNullException(nameof(rssFeedService)); this.presentationService = presentationService ?? throw new ArgumentNullException(nameof(presentationService)); }
/// <summary> /// Initializes a new instance of the <see cref="FeedController"/> class. /// </summary> /// <param name="currentUserProvider">currentUserProvider.</param> /// <param name="logger">logger.</param> public FeedController(ICurrentUserProvider currentUserProvider, ILogger logger) { this.feedService = new RssFeedService(currentUserProvider, logger); }
/// <summary> /// Initializes <see cref="RssFeedController"/> /// </summary> public RssFeedController(RssFeedService rssFeedService) { this.RssFeedService = rssFeedService; }