1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2024-12-16 11:37:58 +02:00
Sonarr/NzbDrone.Core.Test/ProviderTests/DownloadProviderTest.cs

69 lines
2.4 KiB
C#
Raw Normal View History

using System;
using AutoMoq;
using FizzWare.NBuilder;
using Moq;
2011-06-03 00:06:46 +03:00
using NUnit.Framework;
using NzbDrone.Core.Model;
using NzbDrone.Core.Providers;
using NzbDrone.Core.Repository;
2011-05-28 22:23:35 +03:00
using NzbDrone.Core.Repository.Quality;
using NzbDrone.Core.Test.Framework;
// ReSharper disable InconsistentNaming
2011-05-28 22:23:35 +03:00
namespace NzbDrone.Core.Test.ProviderTests
{
[TestFixture]
public class DownloadProviderTest : TestBase
{
[Test]
public void Download_report_should_send_to_sab_add_to_history_mark_as_grabbed()
{
var mocker = new AutoMoqer(MockBehavior.Strict);
var parseResult = Builder<EpisodeParseResult>.CreateNew()
2011-06-22 04:12:20 +03:00
.With(c => c.Quality = new Quality(QualityTypes.DVD, false))
.Build();
2011-06-22 05:41:06 +03:00
2011-06-22 04:12:20 +03:00
var episodes = Builder<Episode>.CreateListOfSize(2)
2011-10-19 00:46:06 +03:00
.TheFirst(1).Has(s => s.EpisodeId = 12)
2011-05-28 22:23:35 +03:00
.AndTheNext(1).Has(s => s.EpisodeId = 99)
2011-10-19 00:46:06 +03:00
.All().Has(s => s.SeriesId = 5)
2011-06-22 04:12:20 +03:00
.Build();
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 22:23:35 +03:00
.Setup(s => s.GetSabTitle(parseResult))
.Returns(sabTitle);
mocker.GetMock<HistoryProvider>()
.Setup(s => s.Add(It.Is<History>(h => h.EpisodeId == 12 && h.SeriesId == 5)));
mocker.GetMock<HistoryProvider>()
.Setup(s => s.Add(It.Is<History>(h => h.EpisodeId == 99 && h.SeriesId == 5)));
2011-06-22 04:12:20 +03:00
mocker.GetMock<EpisodeProvider>()
.Setup(c => c.GetEpisodesByParseResult(It.IsAny<EpisodeParseResult>(), false)).Returns(episodes);
mocker.GetMock<EpisodeProvider>()
.Setup(c => c.MarkEpisodeAsFetched(12));
mocker.GetMock<EpisodeProvider>()
.Setup(c => c.MarkEpisodeAsFetched(99));
mocker.GetMock<ExternalNotificationProvider>()
.Setup(c => c.OnGrab(It.IsAny<string>()));
mocker.Resolve<DownloadProvider>().DownloadReport(parseResult);
mocker.VerifyAllMocks();
}
}
2011-05-28 22:23:35 +03:00
}