2013-03-28 22:07:09 +00:00
|
|
|
|
|
2012-12-19 16:41:51 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using FluentAssertions;
|
|
|
|
|
using Moq;
|
|
|
|
|
using NUnit.Framework;
|
|
|
|
|
using NzbDrone.Common;
|
2013-03-04 05:53:02 +00:00
|
|
|
|
using NzbDrone.Core.MetadataSource;
|
2012-12-19 16:41:51 +00:00
|
|
|
|
using NzbDrone.Core.Providers;
|
|
|
|
|
using NzbDrone.Core.Test.Framework;
|
|
|
|
|
using NzbDrone.Test.Common;
|
|
|
|
|
|
|
|
|
|
namespace NzbDrone.Core.Test.ProviderTests.TvRageProviderTests
|
|
|
|
|
{
|
|
|
|
|
[TestFixture]
|
2013-03-28 22:07:09 +00:00
|
|
|
|
|
2013-02-17 05:44:06 +00:00
|
|
|
|
public class GetSeriesFixture : CoreTest
|
2012-12-19 16:41:51 +00:00
|
|
|
|
{
|
|
|
|
|
private const string showinfo = "http://services.tvrage.com/feeds/showinfo.php?key=NW4v0PSmQIoVmpbASLdD&sid=";
|
|
|
|
|
|
|
|
|
|
private void WithEmptyResults()
|
|
|
|
|
{
|
|
|
|
|
Mocker.GetMock<HttpProvider>()
|
|
|
|
|
.Setup(s => s.DownloadStream(It.Is<String>(u => u.StartsWith(showinfo)), null))
|
2013-03-28 22:07:09 +00:00
|
|
|
|
.Returns(OpenRead("Files", "TVRage", "SeriesInfo_empty.xml"));
|
2012-12-19 16:41:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void WithOneResult()
|
|
|
|
|
{
|
|
|
|
|
Mocker.GetMock<HttpProvider>()
|
|
|
|
|
.Setup(s => s.DownloadStream(It.Is<String>(u => u.StartsWith(showinfo)), null))
|
2013-03-28 22:07:09 +00:00
|
|
|
|
.Returns(OpenRead("Files", "TVRage", "SeriesInfo_one.xml"));
|
2012-12-19 16:41:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void should_be_null_when_no_showinfo_is_returned()
|
|
|
|
|
{
|
|
|
|
|
WithEmptyResults();
|
2013-03-04 05:53:02 +00:00
|
|
|
|
Mocker.Resolve<TvRageProxy>().GetSeries(100).Should().BeNull();
|
2012-12-20 04:48:05 +00:00
|
|
|
|
|
|
|
|
|
ExceptionVerification.ExpectedWarns(1);
|
2012-12-19 16:41:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void should_return_series_when_showinfo_is_valid()
|
|
|
|
|
{
|
|
|
|
|
WithOneResult();
|
2013-03-04 05:53:02 +00:00
|
|
|
|
var result = Mocker.Resolve<TvRageProxy>().GetSeries(29999);
|
2012-12-19 16:41:51 +00:00
|
|
|
|
|
|
|
|
|
result.ShowId.Should().Be(29999);
|
|
|
|
|
result.Name.Should().Be("Anger Management");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|