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