using Microsoft.Extensions.Configuration; using Newsbot.Collector.Services.Jobs; namespace Newsbot.Collector.Tests.Jobs; public class RssWatcherJobTest { private IConfiguration GetConfiguration() { var inMemorySettings = new Dictionary { {"ConnectionStrings:database", "Host=localhost;Username=postgres;Password=postgres;Database=postgres;sslmode=disable"} }; IConfiguration configuration = new ConfigurationBuilder() .AddInMemoryCollection(inMemorySettings) .Build(); return configuration; } private string ConnectionString() { return "Host=localhost;Username=postgres;Password=postgres;Database=postgres;sslmode=disable"; } [Fact] public void CanFindItemsNoDb() { var url = "https://www.engadget.com/rss.xml"; var client = new RssWatcherJob(); var items = client.Collect(url, Guid.NewGuid(), 0); } [Fact] public void CanAddItemsToDb() { var url = "https://www.engadget.com/rss.xml"; var client = new RssWatcherJob(); client.Init(ConnectionString()); var items = client.Collect(url, Guid.NewGuid(), 0); client.UpdateDatabase(items); } [Fact] public void CanReadHtmlDrivenFeedPage() { var url = "https://www.howtogeek.com/feed/"; var client = new RssWatcherJob(); client.Init(ConnectionString()); var items = client.Collect(url, Guid.NewGuid(), 0); Console.WriteLine('k'); } [Fact] public void InitAndExecuteTest() { var client = new RssWatcherJob(); client.InitAndExecute(new RssWatcherJobOptions { ConnectionString = ConnectionString() }); } }