1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2024-12-16 11:37:58 +02:00
Sonarr/NzbDrone.Core.Test/Housekeeping/Housekeepers/CleanupOrphanedEpisodesFixture.cs
2013-09-18 22:49:36 -07:00

44 lines
1.3 KiB
C#

using FizzWare.NBuilder;
using FluentAssertions;
using NUnit.Framework;
using NzbDrone.Core.Housekeeping.Housekeepers;
using NzbDrone.Core.Test.Framework;
using NzbDrone.Core.Tv;
namespace NzbDrone.Core.Test.Housekeeping.Housekeepers
{
[TestFixture]
public class CleanupOrphanedEpisodesFixture : DbTest<CleanupOrphanedEpisodes, Episode>
{
[Test]
public void should_delete_orphaned_episodes()
{
var episode = Builder<Episode>.CreateNew()
.BuildNew();
Db.Insert(episode);
Subject.Clean();
AllStoredModels.Should().BeEmpty();
}
[Test]
public void should_not_delete_unorphaned_episodes()
{
var series = Builder<Series>.CreateNew()
.BuildNew();
Db.Insert(series);
var episodes = Builder<Episode>.CreateListOfSize(2)
.TheFirst(1)
.With(e => e.SeriesId = series.Id)
.BuildListOfNew();
Db.InsertMany(episodes);
Subject.Clean();
AllStoredModels.Should().HaveCount(1);
AllStoredModels.Should().Contain(e => e.SeriesId == series.Id);
}
}
}