2010-09-27 03:22:44 +03:00
|
|
|
using System;
|
2010-09-28 03:27:02 +03:00
|
|
|
using System.Collections;
|
2010-09-27 03:22:44 +03:00
|
|
|
using System.Collections.Generic;
|
2010-09-28 06:04:39 +03:00
|
|
|
using System.IO;
|
2010-09-27 03:22:44 +03:00
|
|
|
using System.Text;
|
2010-09-28 03:27:02 +03:00
|
|
|
using FizzWare.NBuilder;
|
2010-09-27 03:22:44 +03:00
|
|
|
using Gallio.Framework;
|
|
|
|
using MbUnit.Framework;
|
|
|
|
using MbUnit.Framework.ContractVerifiers;
|
|
|
|
using Moq;
|
2010-09-28 03:27:02 +03:00
|
|
|
using Ninject;
|
|
|
|
using Ninject.Moq;
|
2010-09-28 07:25:41 +03:00
|
|
|
using NzbDrone.Core.Providers;
|
2010-10-21 04:49:23 +03:00
|
|
|
using NzbDrone.Core.Repository;
|
2010-09-28 03:27:02 +03:00
|
|
|
using SubSonic.Repository;
|
|
|
|
using TvdbLib.Data;
|
2010-10-01 03:09:22 +03:00
|
|
|
using System.Linq;
|
2010-09-27 03:22:44 +03:00
|
|
|
|
|
|
|
// ReSharper disable InconsistentNaming
|
|
|
|
namespace NzbDrone.Core.Test
|
|
|
|
{
|
|
|
|
[TestFixture]
|
2010-10-08 01:17:24 +03:00
|
|
|
// ReSharper disable InconsistentNaming
|
2010-10-05 09:21:18 +03:00
|
|
|
public class SeriesProviderTest
|
2010-09-27 03:22:44 +03:00
|
|
|
{
|
|
|
|
[Test]
|
2010-10-04 04:00:50 +03:00
|
|
|
public void Map_path_to_series()
|
2010-09-27 03:22:44 +03:00
|
|
|
{
|
|
|
|
//Arrange
|
2010-10-02 22:01:43 +03:00
|
|
|
TvdbSeries fakeSeries = Builder<TvdbSeries>.CreateNew().With(f => f.SeriesName = "The Simpsons").Build();
|
2010-10-04 04:00:50 +03:00
|
|
|
var fakeSearch = Builder<TvdbSearchResult>.CreateNew().Build();
|
|
|
|
fakeSearch.Id = fakeSeries.Id;
|
|
|
|
fakeSearch.SeriesName = fakeSeries.SeriesName;
|
2010-10-02 22:01:43 +03:00
|
|
|
|
|
|
|
var moqData = new Mock<IRepository>();
|
|
|
|
var moqTvdb = new Mock<ITvDbProvider>();
|
|
|
|
|
2010-10-05 09:21:18 +03:00
|
|
|
moqData.Setup(f => f.Exists<Series>(c => c.SeriesId == It.IsAny<int>())).Returns(false);
|
2010-10-01 03:09:22 +03:00
|
|
|
|
2010-10-04 04:00:50 +03:00
|
|
|
moqTvdb.Setup(f => f.GetSeries(It.IsAny<String>())).Returns(fakeSearch);
|
2010-10-05 09:21:18 +03:00
|
|
|
moqTvdb.Setup(f => f.GetSeries(fakeSeries.Id, false)).Returns(fakeSeries).Verifiable();
|
2010-10-02 22:01:43 +03:00
|
|
|
|
|
|
|
var kernel = new MockingKernel();
|
|
|
|
kernel.Bind<IRepository>().ToConstant(moqData.Object);
|
|
|
|
kernel.Bind<ITvDbProvider>().ToConstant(moqTvdb.Object);
|
|
|
|
kernel.Bind<ISeriesProvider>().To<SeriesProvider>();
|
|
|
|
|
|
|
|
//Act
|
|
|
|
var seriesController = kernel.Get<ISeriesProvider>();
|
2010-10-04 04:00:50 +03:00
|
|
|
var mappedSeries = seriesController.MapPathToSeries(@"D:\TV Shows\The Simpsons");
|
2010-10-02 22:01:43 +03:00
|
|
|
|
|
|
|
//Assert
|
2010-10-05 09:21:18 +03:00
|
|
|
moqTvdb.VerifyAll();
|
2010-10-04 04:00:50 +03:00
|
|
|
Assert.AreEqual(fakeSeries, mappedSeries);
|
|
|
|
}
|
|
|
|
|
2011-04-01 09:36:34 +03:00
|
|
|
[Test]
|
|
|
|
public void Add_new_series()
|
|
|
|
{
|
|
|
|
var repo = MockLib.GetEmptyRepository();
|
|
|
|
|
|
|
|
var kernel = new MockingKernel();
|
|
|
|
kernel.Bind<ISeriesProvider>().To<SeriesProvider>();
|
|
|
|
kernel.Bind<IRepository>().ToConstant(repo);
|
|
|
|
|
|
|
|
string path = "C:\\Test\\";
|
|
|
|
int tvDbId = 1234;
|
|
|
|
int qualityProfileId = 2;
|
|
|
|
|
|
|
|
//Act
|
|
|
|
var seriesProvider = kernel.Get<ISeriesProvider>();
|
|
|
|
seriesProvider.AddSeries(path, tvDbId, qualityProfileId);
|
|
|
|
|
|
|
|
|
|
|
|
//Assert
|
|
|
|
var series = seriesProvider.GetAllSeries();
|
|
|
|
Assert.IsNotEmpty(series);
|
|
|
|
Assert.Count(1, series);
|
|
|
|
Assert.AreEqual(path, series.First().Path);
|
|
|
|
Assert.AreEqual(tvDbId, series.First().SeriesId);
|
|
|
|
Assert.AreEqual(qualityProfileId, series.First().QualityProfileId);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2010-10-04 04:00:50 +03:00
|
|
|
[Test]
|
|
|
|
[Row(new object[] { "That's Life - 2x03 -The Devil and Miss DeLucca", "That's Life" })]
|
|
|
|
[Row(new object[] { "Van.Duin.Op.Zn.Best.S02E05.DUTCH.WS.PDTV.XViD-DiFFERENT", "Van Duin Op Zn Best" })]
|
|
|
|
[Row(new object[] { "Dollhouse.S02E06.The.Left.Hand.720p.BluRay.x264-SiNNERS", "Dollhouse" })]
|
|
|
|
[Row(new object[] { "Heroes.S02.COMPLETE.German.PROPER.DVDRip.XviD-Prim3time", "Heroes" })]
|
2010-10-21 04:49:23 +03:00
|
|
|
[Ignore("should be updated to validate agains a remote episode instance rather than just the title string")]
|
2010-10-04 04:00:50 +03:00
|
|
|
public void Test_Parse_Success(string postTitle, string title)
|
|
|
|
{
|
2010-10-21 04:49:23 +03:00
|
|
|
var result = Parser.ParseEpisodeInfo(postTitle);
|
|
|
|
//Assert.AreEqual(title, result, postTitle);
|
2010-10-02 22:01:43 +03:00
|
|
|
}
|
|
|
|
|
2011-03-09 09:40:48 +02:00
|
|
|
//[Test]
|
|
|
|
//public void get_unmapped()
|
|
|
|
//{
|
|
|
|
// //Setup
|
|
|
|
// var kernel = new MockingKernel();
|
2010-10-05 09:21:18 +03:00
|
|
|
|
|
|
|
|
2011-03-09 09:40:48 +02:00
|
|
|
// kernel.Bind<ISeriesProvider>().To<SeriesProvider>();
|
|
|
|
// kernel.Bind<IDiskProvider>().ToConstant(MockLib.GetStandardDisk(0, 0));
|
|
|
|
// kernel.Bind<IConfigProvider>().ToConstant(MockLib.StandardConfig);
|
2010-10-05 09:21:18 +03:00
|
|
|
|
2011-03-09 09:40:48 +02:00
|
|
|
// var seriesController = kernel.Get<ISeriesProvider>();
|
2010-10-05 09:21:18 +03:00
|
|
|
|
2011-03-09 09:40:48 +02:00
|
|
|
// //Act
|
|
|
|
// var unmappedFolder = seriesController.GetUnmappedFolders();
|
2010-10-05 09:21:18 +03:00
|
|
|
|
2011-03-09 09:40:48 +02:00
|
|
|
// //Assert
|
|
|
|
// Assert.AreElementsEqualIgnoringOrder(MockLib.StandardSeries, unmappedFolder.Values);
|
|
|
|
//}
|
2010-10-05 09:21:18 +03:00
|
|
|
|
2010-10-21 04:49:23 +03:00
|
|
|
|
2010-09-27 03:22:44 +03:00
|
|
|
}
|
|
|
|
}
|