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.
45 lines
1.3 KiB
45 lines
1.3 KiB
7 years ago
|
using FizzWare.NBuilder;
|
||
|
using FluentAssertions;
|
||
|
using NUnit.Framework;
|
||
4 years ago
|
using NzbDrone.Core.Books;
|
||
7 years ago
|
using NzbDrone.Core.Housekeeping.Housekeepers;
|
||
5 years ago
|
using NzbDrone.Core.Test.Framework;
|
||
7 years ago
|
|
||
|
namespace NzbDrone.Core.Test.Housekeeping.Housekeepers
|
||
|
{
|
||
|
[TestFixture]
|
||
4 years ago
|
public class CleanupOrphanedBooksFixture : DbTest<CleanupOrphanedBooks, Book>
|
||
7 years ago
|
{
|
||
|
[Test]
|
||
|
public void should_delete_orphaned_albums()
|
||
|
{
|
||
4 years ago
|
var album = Builder<Book>.CreateNew()
|
||
6 years ago
|
.BuildNew();
|
||
7 years ago
|
|
||
|
Db.Insert(album);
|
||
|
Subject.Clean();
|
||
|
AllStoredModels.Should().BeEmpty();
|
||
|
}
|
||
|
|
||
|
[Test]
|
||
|
public void should_not_delete_unorphaned_albums()
|
||
|
{
|
||
4 years ago
|
var artist = Builder<Author>.CreateNew()
|
||
|
.With(e => e.Metadata = new AuthorMetadata { Id = 1 })
|
||
6 years ago
|
.BuildNew();
|
||
7 years ago
|
|
||
|
Db.Insert(artist);
|
||
|
|
||
4 years ago
|
var albums = Builder<Book>.CreateListOfSize(2)
|
||
6 years ago
|
.TheFirst(1)
|
||
4 years ago
|
.With(e => e.AuthorMetadataId = artist.Metadata.Value.Id)
|
||
6 years ago
|
.BuildListOfNew();
|
||
7 years ago
|
|
||
|
Db.InsertMany(albums);
|
||
|
Subject.Clean();
|
||
|
AllStoredModels.Should().HaveCount(1);
|
||
4 years ago
|
AllStoredModels.Should().Contain(e => e.AuthorMetadataId == artist.Metadata.Value.Id);
|
||
7 years ago
|
}
|
||
|
}
|
||
|
}
|