2011-05-24 06:12:54 +02:00
|
|
|
|
using System;
|
2011-11-14 01:22:18 +01:00
|
|
|
|
|
2011-05-24 06:12:54 +02:00
|
|
|
|
using FizzWare.NBuilder;
|
|
|
|
|
using Moq;
|
2011-06-02 23:06:46 +02:00
|
|
|
|
using NUnit.Framework;
|
2011-05-24 06:12:54 +02:00
|
|
|
|
using NzbDrone.Core.Model;
|
|
|
|
|
using NzbDrone.Core.Providers;
|
|
|
|
|
using NzbDrone.Core.Repository;
|
2011-05-28 21:23:35 +02:00
|
|
|
|
using NzbDrone.Core.Repository.Quality;
|
2011-06-04 03:56:53 +02:00
|
|
|
|
using NzbDrone.Core.Test.Framework;
|
2011-11-14 01:22:18 +01:00
|
|
|
|
using NzbDrone.Test.Common.AutoMoq;
|
2011-05-24 06:12:54 +02:00
|
|
|
|
|
|
|
|
|
// ReSharper disable InconsistentNaming
|
2011-05-28 21:23:35 +02:00
|
|
|
|
|
2011-10-21 01:42:17 +02:00
|
|
|
|
namespace NzbDrone.Core.Test.ProviderTests
|
2011-05-24 06:12:54 +02:00
|
|
|
|
{
|
|
|
|
|
[TestFixture]
|
2011-11-13 08:27:16 +01:00
|
|
|
|
public class DownloadProviderTest : CoreTest
|
2011-05-24 06:12:54 +02:00
|
|
|
|
{
|
|
|
|
|
[Test]
|
2011-07-04 01:04:57 +02:00
|
|
|
|
public void Download_report_should_send_to_sab_add_to_history_mark_as_grabbed()
|
2011-05-24 06:12:54 +02:00
|
|
|
|
{
|
2011-12-15 05:15:53 +01:00
|
|
|
|
WithStrictMocker();
|
2011-05-24 06:12:54 +02:00
|
|
|
|
var parseResult = Builder<EpisodeParseResult>.CreateNew()
|
2011-06-22 03:12:20 +02:00
|
|
|
|
.With(c => c.Quality = new Quality(QualityTypes.DVD, false))
|
|
|
|
|
.Build();
|
2011-06-22 04:41:06 +02:00
|
|
|
|
|
2011-06-22 03:12:20 +02:00
|
|
|
|
var episodes = Builder<Episode>.CreateListOfSize(2)
|
2011-10-23 07:39:14 +02:00
|
|
|
|
.TheFirst(1).With(s => s.EpisodeId = 12)
|
|
|
|
|
.TheNext(1).With(s => s.EpisodeId = 99)
|
|
|
|
|
.All().With(s => s.SeriesId = 5)
|
2011-06-22 03:12:20 +02:00
|
|
|
|
.Build();
|
|
|
|
|
|
2011-05-24 06:12:54 +02:00
|
|
|
|
|
|
|
|
|
const string sabTitle = "My fake sab title";
|
2011-12-15 05:15:53 +01:00
|
|
|
|
Mocker.GetMock<SabProvider>()
|
2012-01-20 06:37:08 +01:00
|
|
|
|
.Setup(s => s.IsInQueue(It.IsAny<EpisodeParseResult>()))
|
2011-05-24 06:12:54 +02:00
|
|
|
|
.Returns(false);
|
|
|
|
|
|
2011-12-15 05:15:53 +01:00
|
|
|
|
Mocker.GetMock<SabProvider>()
|
2011-05-24 06:12:54 +02:00
|
|
|
|
.Setup(s => s.AddByUrl(parseResult.NzbUrl, sabTitle))
|
|
|
|
|
.Returns(true);
|
|
|
|
|
|
2011-12-15 05:15:53 +01:00
|
|
|
|
Mocker.GetMock<SabProvider>()
|
2011-05-28 21:23:35 +02:00
|
|
|
|
.Setup(s => s.GetSabTitle(parseResult))
|
|
|
|
|
.Returns(sabTitle);
|
2011-05-24 06:12:54 +02:00
|
|
|
|
|
2011-12-15 05:15:53 +01:00
|
|
|
|
Mocker.GetMock<HistoryProvider>()
|
2011-06-22 04:15:39 +02:00
|
|
|
|
.Setup(s => s.Add(It.Is<History>(h => h.EpisodeId == 12 && h.SeriesId == 5)));
|
2011-12-15 05:15:53 +01:00
|
|
|
|
Mocker.GetMock<HistoryProvider>()
|
2011-06-22 04:15:39 +02:00
|
|
|
|
.Setup(s => s.Add(It.Is<History>(h => h.EpisodeId == 99 && h.SeriesId == 5)));
|
2011-05-24 06:12:54 +02:00
|
|
|
|
|
2011-12-15 05:15:53 +01:00
|
|
|
|
Mocker.GetMock<EpisodeProvider>()
|
2011-06-22 03:12:20 +02:00
|
|
|
|
.Setup(c => c.GetEpisodesByParseResult(It.IsAny<EpisodeParseResult>(), false)).Returns(episodes);
|
|
|
|
|
|
2011-12-15 05:15:53 +01:00
|
|
|
|
Mocker.GetMock<EpisodeProvider>()
|
2011-07-04 01:04:57 +02:00
|
|
|
|
.Setup(c => c.MarkEpisodeAsFetched(12));
|
|
|
|
|
|
2011-12-15 05:15:53 +01:00
|
|
|
|
Mocker.GetMock<EpisodeProvider>()
|
2011-07-04 01:04:57 +02:00
|
|
|
|
.Setup(c => c.MarkEpisodeAsFetched(99));
|
|
|
|
|
|
2011-12-15 05:15:53 +01:00
|
|
|
|
Mocker.GetMock<ExternalNotificationProvider>()
|
2011-07-29 03:02:21 +02:00
|
|
|
|
.Setup(c => c.OnGrab(It.IsAny<string>()));
|
|
|
|
|
|
2011-12-15 05:15:53 +01:00
|
|
|
|
Mocker.Resolve<DownloadProvider>().DownloadReport(parseResult);
|
2011-05-24 06:12:54 +02:00
|
|
|
|
|
2011-12-15 05:15:53 +01:00
|
|
|
|
Mocker.VerifyAllMocks();
|
2011-05-24 06:12:54 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
2011-05-28 21:23:35 +02:00
|
|
|
|
}
|