|
|
@ -13,6 +13,7 @@ namespace NzbDrone.Core.Test.NotificationTests.Xbmc.Json
|
|
|
|
[TestFixture]
|
|
|
|
[TestFixture]
|
|
|
|
public class GetSeriesPathFixture : CoreTest<JsonApiProvider>
|
|
|
|
public class GetSeriesPathFixture : CoreTest<JsonApiProvider>
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
private const int TVDB_ID = 5;
|
|
|
|
private XbmcSettings _settings;
|
|
|
|
private XbmcSettings _settings;
|
|
|
|
private Series _series;
|
|
|
|
private Series _series;
|
|
|
|
private string _response;
|
|
|
|
private string _response;
|
|
|
@ -25,6 +26,10 @@ namespace NzbDrone.Core.Test.NotificationTests.Xbmc.Json
|
|
|
|
.Build();
|
|
|
|
.Build();
|
|
|
|
|
|
|
|
|
|
|
|
_xbmcSeries = Builder<TvShow>.CreateListOfSize(3)
|
|
|
|
_xbmcSeries = Builder<TvShow>.CreateListOfSize(3)
|
|
|
|
|
|
|
|
.All()
|
|
|
|
|
|
|
|
.With(s => s.ImdbNumber = "0")
|
|
|
|
|
|
|
|
.TheFirst(1)
|
|
|
|
|
|
|
|
.With(s => s.ImdbNumber = TVDB_ID.ToString())
|
|
|
|
.Build()
|
|
|
|
.Build()
|
|
|
|
.ToList();
|
|
|
|
.ToList();
|
|
|
|
|
|
|
|
|
|
|
@ -33,16 +38,16 @@ namespace NzbDrone.Core.Test.NotificationTests.Xbmc.Json
|
|
|
|
.Returns(_xbmcSeries);
|
|
|
|
.Returns(_xbmcSeries);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void WithMatchingTvdbId()
|
|
|
|
private void GivenMatchingTvdbId()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
_series = new Series
|
|
|
|
_series = new Series
|
|
|
|
{
|
|
|
|
{
|
|
|
|
TvdbId = _xbmcSeries.First().ImdbNumber,
|
|
|
|
TvdbId = TVDB_ID,
|
|
|
|
Title = "TV Show"
|
|
|
|
Title = "TV Show"
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void WithMatchingTitle()
|
|
|
|
private void GivenMatchingTitle()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
_series = new Series
|
|
|
|
_series = new Series
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -51,7 +56,7 @@ namespace NzbDrone.Core.Test.NotificationTests.Xbmc.Json
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void WithoutMatchingSeries()
|
|
|
|
private void GivenMatchingSeries()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
_series = new Series
|
|
|
|
_series = new Series
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -63,7 +68,7 @@ namespace NzbDrone.Core.Test.NotificationTests.Xbmc.Json
|
|
|
|
[Test]
|
|
|
|
[Test]
|
|
|
|
public void should_return_null_when_series_is_not_found()
|
|
|
|
public void should_return_null_when_series_is_not_found()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
WithoutMatchingSeries();
|
|
|
|
GivenMatchingSeries();
|
|
|
|
|
|
|
|
|
|
|
|
Subject.GetSeriesPath(_settings, _series).Should().BeNull();
|
|
|
|
Subject.GetSeriesPath(_settings, _series).Should().BeNull();
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -71,7 +76,7 @@ namespace NzbDrone.Core.Test.NotificationTests.Xbmc.Json
|
|
|
|
[Test]
|
|
|
|
[Test]
|
|
|
|
public void should_return_path_when_tvdbId_matches()
|
|
|
|
public void should_return_path_when_tvdbId_matches()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
WithMatchingTvdbId();
|
|
|
|
GivenMatchingTvdbId();
|
|
|
|
|
|
|
|
|
|
|
|
Subject.GetSeriesPath(_settings, _series).Should().Be(_xbmcSeries.First().File);
|
|
|
|
Subject.GetSeriesPath(_settings, _series).Should().Be(_xbmcSeries.First().File);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -79,9 +84,24 @@ namespace NzbDrone.Core.Test.NotificationTests.Xbmc.Json
|
|
|
|
[Test]
|
|
|
|
[Test]
|
|
|
|
public void should_return_path_when_title_matches()
|
|
|
|
public void should_return_path_when_title_matches()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
WithMatchingTitle();
|
|
|
|
GivenMatchingTitle();
|
|
|
|
|
|
|
|
|
|
|
|
Subject.GetSeriesPath(_settings, _series).Should().Be(_xbmcSeries.First().File);
|
|
|
|
Subject.GetSeriesPath(_settings, _series).Should().Be(_xbmcSeries.First().File);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
|
|
|
public void should_not_throw_when_imdb_number_is_not_a_number()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
GivenMatchingTvdbId();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_xbmcSeries.ForEach(s => s.ImdbNumber = "tt12345");
|
|
|
|
|
|
|
|
_xbmcSeries.Last().ImdbNumber = TVDB_ID.ToString();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Mocker.GetMock<IXbmcJsonApiProxy>()
|
|
|
|
|
|
|
|
.Setup(s => s.GetSeries(_settings))
|
|
|
|
|
|
|
|
.Returns(_xbmcSeries);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Subject.GetSeriesPath(_settings, _series).Should().NotBeNull();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|