2011-05-24 06:12:54 +02:00
|
|
|
|
using System;
|
|
|
|
|
using AutoMoq;
|
|
|
|
|
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-05-24 06:12:54 +02:00
|
|
|
|
|
|
|
|
|
// ReSharper disable InconsistentNaming
|
2011-05-28 21:23:35 +02:00
|
|
|
|
|
2011-05-24 06:12:54 +02:00
|
|
|
|
namespace NzbDrone.Core.Test
|
|
|
|
|
{
|
|
|
|
|
[TestFixture]
|
2011-06-04 03:56:53 +02:00
|
|
|
|
public class DownloadProviderTest : TestBase
|
2011-05-24 06:12:54 +02:00
|
|
|
|
{
|
|
|
|
|
[Test]
|
|
|
|
|
public void Download_report_should_send_to_sab_and_add_to_history()
|
|
|
|
|
{
|
|
|
|
|
var mocker = new AutoMoqer(MockBehavior.Strict);
|
|
|
|
|
var parseResult = Builder<EpisodeParseResult>.CreateNew()
|
|
|
|
|
.With(e => e.Episodes = Builder<Episode>.CreateListOfSize(2)
|
2011-05-28 21:23:35 +02:00
|
|
|
|
.WhereTheFirst(1).Has(s => s.EpisodeId = 12)
|
|
|
|
|
.AndTheNext(1).Has(s => s.EpisodeId = 99)
|
2011-06-22 04:15:39 +02:00
|
|
|
|
.WhereAll().Has(s => s.SeriesId = 5)
|
2011-05-28 21:23:35 +02:00
|
|
|
|
.Build())
|
|
|
|
|
.With(c => c.Quality = new Quality(QualityTypes.DVD, false))
|
|
|
|
|
.Build();
|
2011-05-24 06:12:54 +02:00
|
|
|
|
|
|
|
|
|
const string sabTitle = "My fake sab title";
|
|
|
|
|
mocker.GetMock<SabProvider>()
|
|
|
|
|
.Setup(s => s.IsInQueue(It.IsAny<String>()))
|
|
|
|
|
.Returns(false);
|
|
|
|
|
|
|
|
|
|
mocker.GetMock<SabProvider>()
|
|
|
|
|
.Setup(s => s.AddByUrl(parseResult.NzbUrl, sabTitle))
|
|
|
|
|
.Returns(true);
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
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-05-24 06:12:54 +02: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
|
|
|
|
|
|
|
|
|
mocker.Resolve<DownloadProvider>().DownloadReport(parseResult);
|
|
|
|
|
|
|
|
|
|
mocker.VerifyAllMocks();
|
|
|
|
|
}
|
|
|
|
|
}
|
2011-05-28 21:23:35 +02:00
|
|
|
|
}
|