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-27 03:22:44 +03:00
|
|
|
using NzbDrone.Core.Controllers;
|
2010-09-28 03:27:02 +03:00
|
|
|
using NzbDrone.Core.Repository;
|
|
|
|
using SubSonic.Repository;
|
|
|
|
using TvdbLib.Data;
|
2010-09-27 03:22:44 +03:00
|
|
|
|
|
|
|
// ReSharper disable InconsistentNaming
|
|
|
|
namespace NzbDrone.Core.Test
|
|
|
|
{
|
|
|
|
[TestFixture]
|
|
|
|
public class SeriesTest
|
|
|
|
{
|
|
|
|
[Test]
|
2010-09-28 06:04:39 +03:00
|
|
|
[Ignore("Can't get it to work")]
|
2010-09-27 03:22:44 +03:00
|
|
|
[Description("This test will confirm that a folder will be skipped if it has been resolved to a series already assigned to another folder")]
|
|
|
|
public void skip_same_series_diffrent_folder()
|
|
|
|
{
|
2010-09-28 03:27:02 +03:00
|
|
|
var tvDbId = 1234;
|
|
|
|
|
2010-09-27 03:22:44 +03:00
|
|
|
//Arrange
|
2010-09-28 03:27:02 +03:00
|
|
|
var moqData = new Mock<IRepository>();
|
|
|
|
var moqTvdb = new Mock<ITvDbController>();
|
|
|
|
|
|
|
|
//setup db to return a fake series
|
|
|
|
Series fakeSeries = Builder<Series>.CreateNew()
|
|
|
|
.With(f => f.TvdbId = tvDbId.ToString())
|
|
|
|
.Build();
|
|
|
|
|
2010-09-28 06:04:39 +03:00
|
|
|
moqData.Setup(f => f.Exists<Series>(c => c.TvdbId == tvDbId.ToString())).
|
|
|
|
Returns(true);
|
2010-09-28 03:27:02 +03:00
|
|
|
|
|
|
|
//setup tvdb to return the same show,
|
|
|
|
IList<TvdbSearchResult> fakeSearchResult = Builder<TvdbSearchResult>.CreateListOfSize(4).WhereTheFirst(1).Has(f => f.Id = tvDbId).Build();
|
2010-09-28 06:04:39 +03:00
|
|
|
TvdbSeries fakeTvDbSeries = Builder<TvdbSeries>.CreateNew()
|
|
|
|
.With(f => f.Id = tvDbId)
|
|
|
|
.Build();
|
|
|
|
|
|
|
|
moqTvdb.Setup(f => f.GetSeries(It.IsAny<int>(), It.IsAny<TvdbLanguage>())).Returns(fakeTvDbSeries);
|
2010-09-28 03:27:02 +03:00
|
|
|
moqTvdb.Setup(f => f.SearchSeries(It.IsAny<string>())).
|
2010-09-28 06:04:39 +03:00
|
|
|
Returns(fakeSearchResult);
|
2010-09-28 03:27:02 +03:00
|
|
|
|
|
|
|
var kernel = new MockingKernel();
|
|
|
|
kernel.Bind<IRepository>().ToConstant(moqData.Object);
|
|
|
|
kernel.Bind<ITvDbController>().ToConstant(moqTvdb.Object);
|
2010-09-28 06:04:39 +03:00
|
|
|
kernel.Bind<IConfigController>().ToConstant(MockLib.StandardConfig);
|
|
|
|
kernel.Bind<IDiskController>().ToConstant(MockLib.StandardDisk);
|
|
|
|
kernel.Bind<ISeriesController>().To<SeriesController>();
|
2010-09-28 03:27:02 +03:00
|
|
|
|
2010-09-28 06:04:39 +03:00
|
|
|
|
|
|
|
//Act
|
2010-09-28 03:27:02 +03:00
|
|
|
var seriesController = kernel.Get<ISeriesController>();
|
2010-09-28 06:04:39 +03:00
|
|
|
seriesController.SyncSeriesWithDisk();
|
|
|
|
|
|
|
|
//Assert
|
|
|
|
//Verify that the show was added to the database only once.
|
|
|
|
moqData.Verify(c => c.Add(It.IsAny<Series>()), Times.Once());
|
2010-09-27 03:22:44 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|