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.
50 lines
1.7 KiB
50 lines
1.7 KiB
7 years ago
|
using System.Linq;
|
||
11 years ago
|
using FizzWare.NBuilder;
|
||
|
using FluentAssertions;
|
||
|
using NUnit.Framework;
|
||
|
using NzbDrone.Core.Housekeeping.Housekeepers;
|
||
|
using NzbDrone.Core.MediaFiles;
|
||
|
using NzbDrone.Core.Test.Framework;
|
||
7 years ago
|
using NzbDrone.Core.Music;
|
||
10 years ago
|
using NzbDrone.Core.Qualities;
|
||
11 years ago
|
|
||
|
namespace NzbDrone.Core.Test.Housekeeping.Housekeepers
|
||
|
{
|
||
|
[TestFixture]
|
||
7 years ago
|
public class CleanupOrphanedTrackFilesFixture : DbTest<CleanupOrphanedTrackFiles, TrackFile>
|
||
11 years ago
|
{
|
||
|
[Test]
|
||
7 years ago
|
public void should_delete_orphaned_track_files()
|
||
11 years ago
|
{
|
||
7 years ago
|
var trackFile = Builder<TrackFile>.CreateNew()
|
||
10 years ago
|
.With(h => h.Quality = new QualityModel())
|
||
11 years ago
|
.BuildNew();
|
||
|
|
||
7 years ago
|
Db.Insert(trackFile);
|
||
11 years ago
|
Subject.Clean();
|
||
|
AllStoredModels.Should().BeEmpty();
|
||
|
}
|
||
|
|
||
|
[Test]
|
||
7 years ago
|
public void should_not_delete_unorphaned_track_files()
|
||
11 years ago
|
{
|
||
7 years ago
|
var trackFiles = Builder<TrackFile>.CreateListOfSize(2)
|
||
10 years ago
|
.All()
|
||
|
.With(h => h.Quality = new QualityModel())
|
||
11 years ago
|
.BuildListOfNew();
|
||
|
|
||
7 years ago
|
Db.InsertMany(trackFiles);
|
||
11 years ago
|
|
||
7 years ago
|
var track = Builder<Track>.CreateNew()
|
||
|
.With(e => e.TrackFileId = trackFiles.First().Id)
|
||
11 years ago
|
.BuildNew();
|
||
|
|
||
7 years ago
|
Db.Insert(track);
|
||
11 years ago
|
|
||
|
Subject.Clean();
|
||
|
AllStoredModels.Should().HaveCount(1);
|
||
7 years ago
|
Db.All<Track>().Should().Contain(e => e.TrackFileId == AllStoredModels.First().Id);
|
||
11 years ago
|
}
|
||
|
}
|
||
|
}
|