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.
48 lines
1.7 KiB
48 lines
1.7 KiB
3 years ago
|
using FizzWare.NBuilder;
|
||
|
using FluentAssertions;
|
||
|
using NUnit.Framework;
|
||
|
using NzbDrone.Core.Housekeeping.Housekeepers;
|
||
|
using NzbDrone.Core.Movies;
|
||
|
using NzbDrone.Core.Movies.Collections;
|
||
|
using NzbDrone.Core.Test.Framework;
|
||
|
|
||
|
namespace NzbDrone.Core.Test.Housekeeping.Housekeepers
|
||
|
{
|
||
|
[TestFixture]
|
||
|
public class CleanupOrphanedCollectionsFixture : DbTest<CleanupOrphanedCollections, MovieCollection>
|
||
|
{
|
||
|
[Test]
|
||
|
public void should_delete_orphaned_collection_item()
|
||
|
{
|
||
|
var collection = Builder<MovieCollection>.CreateNew()
|
||
|
.With(h => h.Id = 3)
|
||
|
.With(h => h.TmdbId = 123456)
|
||
|
.With(h => h.Title = "Some Credit")
|
||
|
.BuildNew();
|
||
|
|
||
|
Db.Insert(collection);
|
||
|
Subject.Clean();
|
||
|
AllStoredModels.Should().BeEmpty();
|
||
|
}
|
||
|
|
||
|
[Test]
|
||
|
public void should_not_delete_unorphaned_collection_items()
|
||
|
{
|
||
|
var collection = Builder<MovieCollection>.CreateNew()
|
||
|
.With(h => h.Id = 3)
|
||
|
.With(h => h.TmdbId = 123456)
|
||
|
.With(h => h.Title = "Some Credit")
|
||
|
.BuildNew();
|
||
|
|
||
|
Db.Insert(collection);
|
||
|
|
||
|
var movie = Builder<MovieMetadata>.CreateNew().With(m => m.CollectionTmdbId = collection.TmdbId).BuildNew();
|
||
|
|
||
|
Db.Insert(movie);
|
||
|
|
||
|
Subject.Clean();
|
||
|
AllStoredModels.Should().HaveCount(1);
|
||
|
}
|
||
|
}
|
||
|
}
|