mirror of https://github.com/Radarr/Radarr
75 lines
2.4 KiB
C#
75 lines
2.4 KiB
C#
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using FizzWare.NBuilder;
|
|
using Moq;
|
|
using NUnit.Framework;
|
|
using NzbDrone.Core.MediaFiles;
|
|
using NzbDrone.Core.Movies;
|
|
using NzbDrone.Core.Notifications;
|
|
using NzbDrone.Core.Notifications.Xbmc;
|
|
using NzbDrone.Core.Test.Framework;
|
|
|
|
namespace NzbDrone.Core.Test.NotificationTests.Xbmc
|
|
{
|
|
[TestFixture]
|
|
public class OnDownloadFixture : CoreTest<Notifications.Xbmc.Xbmc>
|
|
{
|
|
private DownloadMessage _downloadMessage;
|
|
|
|
[SetUp]
|
|
public void Setup()
|
|
{
|
|
var movie = Builder<Movie>.CreateNew()
|
|
.Build();
|
|
|
|
var movieFile = Builder<MovieFile>.CreateNew()
|
|
.Build();
|
|
|
|
_downloadMessage = Builder<DownloadMessage>.CreateNew()
|
|
.With(d => d.Movie = movie)
|
|
.With(d => d.MovieFile = movieFile)
|
|
.With(d => d.OldMovieFiles = new List<DeletedMovieFile>())
|
|
.Build();
|
|
|
|
Subject.Definition = new NotificationDefinition();
|
|
Subject.Definition.Settings = new XbmcSettings
|
|
{
|
|
UpdateLibrary = true
|
|
};
|
|
}
|
|
|
|
private void GivenOldFiles()
|
|
{
|
|
_downloadMessage.OldMovieFiles = Builder<DeletedMovieFile>
|
|
.CreateListOfSize(1)
|
|
.All()
|
|
.WithFactory(() => new DeletedMovieFile(Builder<MovieFile>.CreateNew().Build(), null))
|
|
.Build()
|
|
.ToList();
|
|
|
|
Subject.Definition.Settings = new XbmcSettings
|
|
{
|
|
UpdateLibrary = true,
|
|
CleanLibrary = true
|
|
};
|
|
}
|
|
|
|
[Test]
|
|
public void should_not_clean_if_no_movie_was_replaced()
|
|
{
|
|
Subject.OnDownload(_downloadMessage);
|
|
|
|
Mocker.GetMock<IXbmcService>().Verify(v => v.Clean(It.IsAny<XbmcSettings>()), Times.Never());
|
|
}
|
|
|
|
[Test]
|
|
public void should_clean_if_movie_was_replaced()
|
|
{
|
|
GivenOldFiles();
|
|
Subject.OnDownload(_downloadMessage);
|
|
|
|
Mocker.GetMock<IXbmcService>().Verify(v => v.Clean(It.IsAny<XbmcSettings>()), Times.Once());
|
|
}
|
|
}
|
|
}
|