2022-07-19 20:08:53 +00:00
|
|
|
using System;
|
2014-04-01 20:07:41 +00:00
|
|
|
using System.Collections.Generic;
|
2013-10-24 15:34:39 +00:00
|
|
|
using Moq;
|
|
|
|
using NUnit.Framework;
|
2021-08-19 21:35:06 +00:00
|
|
|
using NzbDrone.Core.Blocklisting;
|
2013-10-24 15:34:39 +00:00
|
|
|
using NzbDrone.Core.Download;
|
2022-07-19 20:08:53 +00:00
|
|
|
using NzbDrone.Core.Indexers;
|
2013-10-24 15:34:39 +00:00
|
|
|
using NzbDrone.Core.Qualities;
|
|
|
|
using NzbDrone.Core.Test.Framework;
|
|
|
|
|
2021-08-19 21:35:06 +00:00
|
|
|
namespace NzbDrone.Core.Test.Blocklisting
|
2013-10-24 15:34:39 +00:00
|
|
|
{
|
|
|
|
[TestFixture]
|
2021-08-19 21:35:06 +00:00
|
|
|
public class BlocklistServiceFixture : CoreTest<BlocklistService>
|
2013-10-24 15:34:39 +00:00
|
|
|
{
|
|
|
|
private DownloadFailedEvent _event;
|
|
|
|
|
|
|
|
[SetUp]
|
|
|
|
public void Setup()
|
|
|
|
{
|
|
|
|
_event = new DownloadFailedEvent
|
2020-01-03 12:49:24 +00:00
|
|
|
{
|
|
|
|
ArtistId = 12345,
|
|
|
|
AlbumIds = new List<int> { 1 },
|
|
|
|
Quality = new QualityModel(Quality.MP3_320),
|
|
|
|
SourceTitle = "artist.name.album.title",
|
|
|
|
DownloadClient = "SabnzbdClient",
|
|
|
|
DownloadId = "Sabnzbd_nzo_2dfh73k"
|
|
|
|
};
|
2014-04-01 20:07:41 +00:00
|
|
|
|
|
|
|
_event.Data.Add("publishedDate", DateTime.UtcNow.ToString("s") + "Z");
|
2015-04-20 03:25:59 +00:00
|
|
|
_event.Data.Add("size", "1000");
|
|
|
|
_event.Data.Add("indexer", "nzbs.org");
|
2022-07-19 20:08:53 +00:00
|
|
|
_event.Data.Add("protocol", nameof(UsenetDownloadProtocol));
|
2015-04-20 03:25:59 +00:00
|
|
|
_event.Data.Add("message", "Marked as failed");
|
2022-07-19 20:08:53 +00:00
|
|
|
|
|
|
|
Mocker.SetConstant<IBlocklistForProtocol>(Mocker.Resolve<UsenetBlocklist>());
|
2013-10-24 15:34:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void should_add_to_repository()
|
|
|
|
{
|
|
|
|
Subject.Handle(_event);
|
|
|
|
|
2021-08-19 21:35:06 +00:00
|
|
|
Mocker.GetMock<IBlocklistRepository>()
|
|
|
|
.Verify(v => v.Insert(It.Is<Blocklist>(b => b.AlbumIds == _event.AlbumIds)), Times.Once());
|
2013-10-24 15:34:39 +00:00
|
|
|
}
|
2015-04-20 03:25:59 +00:00
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void should_add_to_repository_missing_size_and_protocol()
|
|
|
|
{
|
|
|
|
Subject.Handle(_event);
|
|
|
|
|
|
|
|
_event.Data.Remove("size");
|
|
|
|
_event.Data.Remove("protocol");
|
|
|
|
|
2021-08-19 21:35:06 +00:00
|
|
|
Mocker.GetMock<IBlocklistRepository>()
|
|
|
|
.Verify(v => v.Insert(It.Is<Blocklist>(b => b.AlbumIds == _event.AlbumIds)), Times.Once());
|
2015-04-20 03:25:59 +00:00
|
|
|
}
|
2013-10-24 15:34:39 +00:00
|
|
|
}
|
|
|
|
}
|