2013-02-20 03:05:15 +01:00
|
|
|
|
using System.Linq;
|
2011-05-22 18:53:21 +02:00
|
|
|
|
using FizzWare.NBuilder;
|
2011-06-02 23:06:46 +02:00
|
|
|
|
using FluentAssertions;
|
2013-02-20 03:05:15 +01:00
|
|
|
|
using Moq;
|
2011-06-02 23:06:46 +02:00
|
|
|
|
using NUnit.Framework;
|
2013-02-24 07:48:52 +01:00
|
|
|
|
using NzbDrone.Core.Configuration;
|
2013-02-19 07:01:03 +01:00
|
|
|
|
using NzbDrone.Core.Tv;
|
2011-06-15 04:31:41 +02:00
|
|
|
|
using NzbDrone.Core.Providers.Core;
|
2011-05-19 05:55:35 +02:00
|
|
|
|
using NzbDrone.Core.Test.Framework;
|
2011-05-22 18:53:21 +02:00
|
|
|
|
|
2013-02-19 07:01:03 +01:00
|
|
|
|
namespace NzbDrone.Core.Test.TvTests
|
2011-05-22 18:53:21 +02:00
|
|
|
|
{
|
|
|
|
|
[TestFixture]
|
2013-02-20 03:05:15 +01:00
|
|
|
|
public class SeriesProviderTest : CoreTest<SeriesService>
|
2011-05-22 18:53:21 +02:00
|
|
|
|
{
|
2013-02-20 03:05:15 +01:00
|
|
|
|
private Mock<ISeriesRepository> Repo;
|
|
|
|
|
|
|
|
|
|
private Series fakeSeries;
|
|
|
|
|
|
2012-10-14 02:54:46 +02:00
|
|
|
|
[SetUp]
|
|
|
|
|
public void Setup()
|
|
|
|
|
{
|
2013-02-20 03:05:15 +01:00
|
|
|
|
Repo = Mocker.GetMock<ISeriesRepository>();
|
|
|
|
|
fakeSeries = Builder<Series>.CreateNew().Build();
|
2012-10-14 02:54:46 +02:00
|
|
|
|
}
|
|
|
|
|
|
2013-02-20 03:05:15 +01:00
|
|
|
|
[Test]
|
|
|
|
|
public void Add_new_series()
|
2011-05-22 18:53:21 +02:00
|
|
|
|
{
|
|
|
|
|
const string path = "C:\\Test\\";
|
2012-02-29 09:25:41 +01:00
|
|
|
|
const string title = "Test Title";
|
2011-05-22 18:53:21 +02:00
|
|
|
|
const int tvDbId = 1234;
|
|
|
|
|
const int qualityProfileId = 2;
|
|
|
|
|
|
2011-06-18 09:17:47 +02:00
|
|
|
|
|
2013-02-20 03:05:15 +01:00
|
|
|
|
Series insertedModel = null;
|
2011-06-18 09:17:47 +02:00
|
|
|
|
|
2013-02-20 03:05:15 +01:00
|
|
|
|
Repo.Setup(c => c.Insert(It.IsAny<Series>()))
|
|
|
|
|
.Callback<Series>(c => insertedModel = c);
|
2011-06-18 09:17:47 +02:00
|
|
|
|
|
2013-02-20 03:05:15 +01:00
|
|
|
|
Subject.AddSeries(title, path, tvDbId, qualityProfileId, null);
|
2011-06-18 09:17:47 +02:00
|
|
|
|
|
2013-02-20 03:05:15 +01:00
|
|
|
|
insertedModel.Should().NotBeNull();
|
|
|
|
|
insertedModel.Path.Should().Be(path);
|
|
|
|
|
insertedModel.SeriesId.Should().Be(tvDbId);
|
|
|
|
|
insertedModel.QualityProfileId.Should().Be(qualityProfileId);
|
|
|
|
|
insertedModel.Title.Should().Be(title);
|
2011-06-18 09:17:47 +02:00
|
|
|
|
}
|
|
|
|
|
|
2013-02-20 03:05:15 +01:00
|
|
|
|
[TestCase(true)]
|
|
|
|
|
[TestCase(false)]
|
|
|
|
|
public void Add_new_series_should_use_config_for_season_folders(bool useSeasonFolder)
|
2011-05-22 18:53:21 +02:00
|
|
|
|
{
|
2013-02-24 07:48:52 +01:00
|
|
|
|
Mocker.GetMock<ConfigService>()
|
2013-02-20 03:05:15 +01:00
|
|
|
|
.Setup(c => c.UseSeasonFolder).Returns(useSeasonFolder);
|
2011-05-22 18:53:21 +02:00
|
|
|
|
|
2013-02-20 03:05:15 +01:00
|
|
|
|
const string path = "C:\\Test\\";
|
|
|
|
|
const string title = "Test Title";
|
|
|
|
|
const int tvDbId = 1234;
|
|
|
|
|
const int qualityProfileId = 2;
|
2011-12-09 01:55:00 +01:00
|
|
|
|
|
2011-12-15 05:29:21 +01:00
|
|
|
|
|
2013-02-20 03:05:15 +01:00
|
|
|
|
Series insertedModel = null;
|
2011-12-15 05:29:21 +01:00
|
|
|
|
|
2013-02-20 03:05:15 +01:00
|
|
|
|
Repo.Setup(c => c.Insert(It.IsAny<Series>()))
|
|
|
|
|
.Callback<Series>(c => insertedModel = c);
|
2011-06-18 09:17:47 +02:00
|
|
|
|
|
2013-02-20 03:05:15 +01:00
|
|
|
|
Subject.AddSeries(title, path, tvDbId, qualityProfileId, null);
|
2011-05-22 18:53:21 +02:00
|
|
|
|
|
2013-02-20 03:05:15 +01:00
|
|
|
|
insertedModel.SeasonFolder = useSeasonFolder;
|
2011-05-22 18:53:21 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void is_monitored()
|
|
|
|
|
{
|
2013-02-20 03:05:15 +01:00
|
|
|
|
Repo.Setup(c => c.Get(12))
|
|
|
|
|
.Returns(fakeSeries);
|
2012-02-28 06:50:56 +01:00
|
|
|
|
|
2013-02-20 03:05:15 +01:00
|
|
|
|
fakeSeries.Monitored = true;
|
2012-02-28 06:50:56 +01:00
|
|
|
|
|
2013-02-20 03:05:15 +01:00
|
|
|
|
Subject.IsMonitored(12).Should().Be(true);
|
2012-02-28 06:50:56 +01:00
|
|
|
|
}
|
2011-05-22 18:53:21 +02:00
|
|
|
|
}
|
2011-04-23 00:24:05 +02:00
|
|
|
|
} |