2023-02-19 21:39:03 -08:00
|
|
|
using Microsoft.Extensions.Configuration;
|
2023-02-16 22:19:05 -08:00
|
|
|
using Newsbot.Collector.Services.Jobs;
|
|
|
|
|
|
|
|
namespace Newsbot.Collector.Tests.Jobs;
|
|
|
|
|
|
|
|
public class RssWatcherJobTest
|
|
|
|
{
|
2023-02-19 21:39:03 -08:00
|
|
|
private IConfiguration GetConfiguration()
|
|
|
|
{
|
|
|
|
var inMemorySettings = new Dictionary<string, string> {
|
|
|
|
{"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);
|
|
|
|
}
|
|
|
|
|
2023-02-16 22:19:05 -08:00
|
|
|
[Fact]
|
2023-02-19 21:39:03 -08:00
|
|
|
public void CanAddItemsToDb()
|
2023-02-16 22:19:05 -08:00
|
|
|
{
|
|
|
|
var url = "https://www.engadget.com/rss.xml";
|
2023-02-19 21:39:03 -08:00
|
|
|
var client = new RssWatcherJob();
|
|
|
|
client.Init(ConnectionString());
|
|
|
|
client.Collect(url, 0);
|
2023-02-16 22:19:05 -08:00
|
|
|
}
|
|
|
|
}
|