You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Lidarr/src/NzbDrone.Core.Test/Housekeeping/Housekeepers/CleanupOrphanedBlacklistFix...

49 lines
1.6 KiB

using System.Collections.Generic;
using FizzWare.NBuilder;
using FluentAssertions;
using NUnit.Framework;
using NzbDrone.Core.Blocklisting;
using NzbDrone.Core.Housekeeping.Housekeepers;
using NzbDrone.Core.Music;
using NzbDrone.Core.Qualities;
using NzbDrone.Core.Test.Framework;
namespace NzbDrone.Core.Test.Housekeeping.Housekeepers
{
[TestFixture]
public class CleanupOrphanedBlocklistFixture : DbTest<CleanupOrphanedBlocklist, Blocklist>
{
[Test]
public void should_delete_orphaned_blocklist_items()
{
var blocklist = Builder<Blocklist>.CreateNew()
.With(h => h.AlbumIds = new List<int>())
.With(h => h.Quality = new QualityModel())
.BuildNew();
Db.Insert(blocklist);
Subject.Clean();
AllStoredModels.Should().BeEmpty();
}
[Test]
public void should_not_delete_unorphaned_blocklist_items()
{
var artist = Builder<Artist>.CreateNew().BuildNew();
Db.Insert(artist);
var blocklist = Builder<Blocklist>.CreateNew()
.With(h => h.AlbumIds = new List<int>())
.With(h => h.Quality = new QualityModel())
.With(b => b.ArtistId = artist.Id)
.BuildNew();
Db.Insert(blocklist);
Subject.Clean();
AllStoredModels.Should().HaveCount(1);
}
}
}