2013-11-20 00:42:17 +00:00
|
|
|
|
using System.Collections.Generic;
|
2013-11-18 06:28:40 +00:00
|
|
|
|
using System.Linq;
|
|
|
|
|
using FizzWare.NBuilder;
|
|
|
|
|
using Moq;
|
|
|
|
|
using NUnit.Framework;
|
|
|
|
|
using NzbDrone.Core.MediaFiles;
|
|
|
|
|
using NzbDrone.Core.Notifications;
|
|
|
|
|
using NzbDrone.Core.Notifications.Xbmc;
|
|
|
|
|
using NzbDrone.Core.Test.Framework;
|
2018-03-14 20:41:36 +00:00
|
|
|
|
using NzbDrone.Core.Movies;
|
2013-11-18 06:28:40 +00:00
|
|
|
|
|
|
|
|
|
namespace NzbDrone.Core.Test.NotificationTests.Xbmc
|
|
|
|
|
{
|
|
|
|
|
[TestFixture]
|
|
|
|
|
public class OnDownloadFixture : CoreTest<Notifications.Xbmc.Xbmc>
|
|
|
|
|
{
|
|
|
|
|
private DownloadMessage _downloadMessage;
|
2019-12-22 21:24:11 +00:00
|
|
|
|
|
2013-11-18 06:28:40 +00:00
|
|
|
|
[SetUp]
|
|
|
|
|
public void Setup()
|
|
|
|
|
{
|
2017-03-06 21:23:25 +00:00
|
|
|
|
var movie = Builder<Movie>.CreateNew()
|
2013-11-18 06:28:40 +00:00
|
|
|
|
.Build();
|
|
|
|
|
|
2017-03-06 21:23:25 +00:00
|
|
|
|
var movieFile = Builder<MovieFile>.CreateNew()
|
2013-11-18 06:28:40 +00:00
|
|
|
|
.Build();
|
|
|
|
|
|
|
|
|
|
_downloadMessage = Builder<DownloadMessage>.CreateNew()
|
2017-03-06 21:23:25 +00:00
|
|
|
|
.With(d => d.Movie = movie)
|
|
|
|
|
.With(d => d.MovieFile = movieFile)
|
|
|
|
|
.With(d => d.OldMovieFiles = new List<MovieFile>())
|
2013-11-18 06:28:40 +00:00
|
|
|
|
.Build();
|
|
|
|
|
|
|
|
|
|
Subject.Definition = new NotificationDefinition();
|
|
|
|
|
Subject.Definition.Settings = new XbmcSettings
|
|
|
|
|
{
|
|
|
|
|
UpdateLibrary = true
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void GivenOldFiles()
|
|
|
|
|
{
|
2017-03-06 21:23:25 +00:00
|
|
|
|
_downloadMessage.OldMovieFiles = Builder<MovieFile>.CreateListOfSize(1)
|
2017-11-10 15:11:09 +00:00
|
|
|
|
.Build()
|
|
|
|
|
.ToList();
|
2013-11-18 06:28:40 +00:00
|
|
|
|
|
|
|
|
|
Subject.Definition.Settings = new XbmcSettings
|
|
|
|
|
{
|
|
|
|
|
UpdateLibrary = true,
|
|
|
|
|
CleanLibrary = true
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
2017-11-10 15:11:09 +00:00
|
|
|
|
public void should_not_clean_if_no_movie_was_replaced()
|
2013-11-18 06:28:40 +00:00
|
|
|
|
{
|
|
|
|
|
Subject.OnDownload(_downloadMessage);
|
|
|
|
|
|
|
|
|
|
Mocker.GetMock<IXbmcService>().Verify(v => v.Clean(It.IsAny<XbmcSettings>()), Times.Never());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
2017-11-10 15:11:09 +00:00
|
|
|
|
public void should_clean_if_movie_was_replaced()
|
2013-11-18 06:28:40 +00:00
|
|
|
|
{
|
|
|
|
|
GivenOldFiles();
|
|
|
|
|
Subject.OnDownload(_downloadMessage);
|
|
|
|
|
|
|
|
|
|
Mocker.GetMock<IXbmcService>().Verify(v => v.Clean(It.IsAny<XbmcSettings>()), Times.Once());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|