updated some tests

pull/4/head
Keivan 14 years ago
parent 7540890987
commit 020a7462c0

@ -31,6 +31,10 @@
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="FizzWare.NBuilder, Version=2.1.9.0, Culture=neutral, PublicKeyToken=5651b03e12e42c12, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>Libs\FizzWare.NBuilder.dll</HintPath>
</Reference>
<Reference Include="Gallio, Version=3.2.0.0, Culture=neutral, PublicKeyToken=eb9cfa67ee6ab36e, processorArchitecture=MSIL" /> <Reference Include="Gallio, Version=3.2.0.0, Culture=neutral, PublicKeyToken=eb9cfa67ee6ab36e, processorArchitecture=MSIL" />
<Reference Include="log4net, Version=1.2.10.0, Culture=neutral, PublicKeyToken=1b44e1d426115821, processorArchitecture=MSIL"> <Reference Include="log4net, Version=1.2.10.0, Culture=neutral, PublicKeyToken=1b44e1d426115821, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion> <SpecificVersion>False</SpecificVersion>
@ -77,8 +81,9 @@
</ProjectReference> </ProjectReference>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Content Include="Moq\Moq.dll" /> <Content Include="Libs\FizzWare.NBuilder.dll" />
<Content Include="Moq\Moq.xml" /> <Content Include="Libs\Moq.dll" />
<Content Include="Libs\Moq.xml" />
</ItemGroup> </ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. <!-- To modify your build process, add your task inside one of the targets below and uncomment it.

@ -1,11 +1,18 @@
using System; using System;
using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text; using System.Text;
using FizzWare.NBuilder;
using Gallio.Framework; using Gallio.Framework;
using MbUnit.Framework; using MbUnit.Framework;
using MbUnit.Framework.ContractVerifiers; using MbUnit.Framework.ContractVerifiers;
using Moq; using Moq;
using Ninject;
using Ninject.Moq;
using NzbDrone.Core.Controllers; using NzbDrone.Core.Controllers;
using NzbDrone.Core.Repository;
using SubSonic.Repository;
using TvdbLib.Data;
// ReSharper disable InconsistentNaming // ReSharper disable InconsistentNaming
namespace NzbDrone.Core.Test namespace NzbDrone.Core.Test
@ -17,8 +24,32 @@ namespace NzbDrone.Core.Test
[Description("This test will confirm that a folder will be skipped if it has been resolved to a series already assigned to another folder")] [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() public void skip_same_series_diffrent_folder()
{ {
var tvDbId = 1234;
//Arrange //Arrange
var seriesProvider = new SeriesController(new Mock<Ilog>(), new Mock<IDiskController>(), new Mock<IConfigController>(), new ) 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();
moqData.Setup(f => f.Single<Series>(tvDbId)).
Returns(fakeSeries);
//setup tvdb to return the same show,
IList<TvdbSearchResult> fakeSearchResult = Builder<TvdbSearchResult>.CreateListOfSize(4).WhereTheFirst(1).Has(f => f.Id = tvDbId).Build();
moqTvdb.Setup(f => f.SearchSeries(It.IsAny<string>())).
Returns(fakeSearchResult);
var kernel = new MockingKernel();
kernel.Bind<IRepository>().ToConstant(moqData.Object);
kernel.Bind<ITvDbController>().ToConstant(moqTvdb.Object);
var seriesController = kernel.Get<ISeriesController>();
seriesController.a
} }
} }
} }

@ -5,7 +5,7 @@ namespace NzbDrone.Core.Controllers
{ {
public interface ITvDbController public interface ITvDbController
{ {
List<TvdbSearchResult> SearchSeries(string name); IList<TvdbSearchResult> SearchSeries(string name);
TvdbSeries GetSeries(int id, TvdbLanguage language); TvdbSeries GetSeries(int id, TvdbLanguage language);
} }
} }

@ -58,7 +58,7 @@ namespace NzbDrone.Core.Controllers
private void AddShow(string path) private void AddShow(string path)
{ {
List<TvdbSearchResult> searchResults = _tvDb.SearchSeries(new DirectoryInfo(path).Name); var searchResults = _tvDb.SearchSeries(new DirectoryInfo(path).Name);
if (searchResults.Count != 0) if (searchResults.Count != 0)
{ {
AddShow(path, _tvDb.GetSeries(searchResults[0].Id, searchResults[0].Language)); AddShow(path, _tvDb.GetSeries(searchResults[0].Id, searchResults[0].Language));

@ -18,7 +18,7 @@ namespace NzbDrone.Core.Controllers
#region ITvDbController Members #region ITvDbController Members
public List<TvdbSearchResult> SearchSeries(string name) public IList<TvdbSearchResult> SearchSeries(string name)
{ {
return _handler.SearchSeries(name); return _handler.SearchSeries(name);
} }

Loading…
Cancel
Save