mirror of
https://github.com/Readarr/Readarr.git
synced 2026-04-24 22:35:39 -04:00
New: Renamed Blacklist to Blocklist
(cherry picked from commit ead1371846b1f19cd49928052be0128bf7ccd41f)
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using FluentAssertions;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.Blocklisting;
|
||||
using NzbDrone.Core.Qualities;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
|
||||
namespace NzbDrone.Core.Test.Blocklisting
|
||||
{
|
||||
[TestFixture]
|
||||
public class BlocklistRepositoryFixture : DbTest<BlocklistRepository, Blocklist>
|
||||
{
|
||||
private Blocklist _blocklist;
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
_blocklist = new Blocklist
|
||||
{
|
||||
AuthorId = 12345,
|
||||
BookIds = new List<int> { 1 },
|
||||
Quality = new QualityModel(Quality.FLAC),
|
||||
SourceTitle = "author.name.book.title",
|
||||
Date = DateTime.UtcNow
|
||||
};
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_be_able_to_write_to_database()
|
||||
{
|
||||
Subject.Insert(_blocklist);
|
||||
Subject.All().Should().HaveCount(1);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_should_have_book_ids()
|
||||
{
|
||||
Subject.Insert(_blocklist);
|
||||
|
||||
Subject.All().First().BookIds.Should().Contain(_blocklist.BookIds);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_check_for_blocklisted_title_case_insensative()
|
||||
{
|
||||
Subject.Insert(_blocklist);
|
||||
|
||||
Subject.BlocklistedByTitle(_blocklist.AuthorId, _blocklist.SourceTitle.ToUpperInvariant()).Should().HaveCount(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.Blocklisting;
|
||||
using NzbDrone.Core.Download;
|
||||
using NzbDrone.Core.Qualities;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
|
||||
namespace NzbDrone.Core.Test.Blocklisting
|
||||
{
|
||||
[TestFixture]
|
||||
public class BlocklistServiceFixture : CoreTest<BlocklistService>
|
||||
{
|
||||
private DownloadFailedEvent _event;
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
_event = new DownloadFailedEvent
|
||||
{
|
||||
AuthorId = 12345,
|
||||
BookIds = new List<int> { 1 },
|
||||
Quality = new QualityModel(Quality.MP3),
|
||||
SourceTitle = "author.name.book.title",
|
||||
DownloadClient = "SabnzbdClient",
|
||||
DownloadId = "Sabnzbd_nzo_2dfh73k"
|
||||
};
|
||||
|
||||
_event.Data.Add("publishedDate", DateTime.UtcNow.ToString("s") + "Z");
|
||||
_event.Data.Add("size", "1000");
|
||||
_event.Data.Add("indexer", "nzbs.org");
|
||||
_event.Data.Add("protocol", "1");
|
||||
_event.Data.Add("message", "Marked as failed");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_add_to_repository()
|
||||
{
|
||||
Subject.Handle(_event);
|
||||
|
||||
Mocker.GetMock<IBlocklistRepository>()
|
||||
.Verify(v => v.Insert(It.Is<Blocklist>(b => b.BookIds == _event.BookIds)), Times.Once());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_add_to_repository_missing_size_and_protocol()
|
||||
{
|
||||
Subject.Handle(_event);
|
||||
|
||||
_event.Data.Remove("size");
|
||||
_event.Data.Remove("protocol");
|
||||
|
||||
Mocker.GetMock<IBlocklistRepository>()
|
||||
.Verify(v => v.Insert(It.Is<Blocklist>(b => b.BookIds == _event.BookIds)), Times.Once());
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user