2012-10-17 05:00:28 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Net;
|
|
|
|
|
using FizzWare.NBuilder;
|
|
|
|
|
using FluentAssertions;
|
|
|
|
|
using Moq;
|
|
|
|
|
using NUnit.Framework;
|
|
|
|
|
using NzbDrone.Common;
|
|
|
|
|
using NzbDrone.Core.Model.Notification;
|
|
|
|
|
using NzbDrone.Core.Providers;
|
2013-03-07 01:51:47 +00:00
|
|
|
|
|
2012-10-17 05:00:28 +00:00
|
|
|
|
using NzbDrone.Core.Test.Framework;
|
|
|
|
|
using NzbDrone.Test.Common.AutoMoq;
|
|
|
|
|
using NzbDrone.Test.Common;
|
|
|
|
|
|
|
|
|
|
namespace NzbDrone.Core.Test.ProviderTests.XemCommunicationProviderTests
|
|
|
|
|
{
|
|
|
|
|
[TestFixture]
|
2013-03-28 22:07:09 +00:00
|
|
|
|
|
2013-02-17 05:44:06 +00:00
|
|
|
|
public class GetSceneTvdbMappingsFixture : CoreTest
|
2012-10-17 05:00:28 +00:00
|
|
|
|
{
|
|
|
|
|
private void WithFailureJson()
|
|
|
|
|
{
|
|
|
|
|
Mocker.GetMock<HttpProvider>().Setup(s => s.DownloadString(It.IsAny<String>()))
|
2013-03-28 19:05:43 +00:00
|
|
|
|
.Returns(ReadAllText("Files","Xem","Failure.txt"));
|
2012-10-17 05:00:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void WithIdsJson()
|
|
|
|
|
{
|
|
|
|
|
Mocker.GetMock<HttpProvider>().Setup(s => s.DownloadString(It.IsAny<String>()))
|
2013-03-28 19:05:43 +00:00
|
|
|
|
.Returns(ReadAllText("Files","Xem","Ids.txt"));
|
2012-10-17 05:00:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void WithMappingsJson()
|
|
|
|
|
{
|
|
|
|
|
Mocker.GetMock<HttpProvider>().Setup(s => s.DownloadString(It.IsAny<String>()))
|
2013-03-28 19:05:43 +00:00
|
|
|
|
.Returns(ReadAllText("Files","Xem","Mappings.txt"));
|
2012-10-17 05:00:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void should_throw_when_failure_is_found()
|
|
|
|
|
{
|
|
|
|
|
WithFailureJson();
|
|
|
|
|
Assert.Throws<Exception>(() => Mocker.Resolve<XemCommunicationProvider>().GetSceneTvdbMappings(12345));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void should_get_list_of_mappings()
|
|
|
|
|
{
|
|
|
|
|
WithMappingsJson();
|
|
|
|
|
Mocker.Resolve<XemCommunicationProvider>().GetSceneTvdbMappings(12345).Should().NotBeEmpty();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void should_have_two_mappings()
|
|
|
|
|
{
|
|
|
|
|
WithMappingsJson();
|
|
|
|
|
Mocker.Resolve<XemCommunicationProvider>().GetSceneTvdbMappings(12345).Should().HaveCount(2);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void should_have_expected_results()
|
|
|
|
|
{
|
|
|
|
|
WithMappingsJson();
|
|
|
|
|
var results = Mocker.Resolve<XemCommunicationProvider>().GetSceneTvdbMappings(12345);
|
|
|
|
|
var first = results.First();
|
|
|
|
|
first.Scene.Absolute.Should().Be(1);
|
|
|
|
|
first.Scene.Season.Should().Be(1);
|
|
|
|
|
first.Scene.Episode.Should().Be(1);
|
|
|
|
|
first.Tvdb.Absolute.Should().Be(1);
|
|
|
|
|
first.Tvdb.Season.Should().Be(1);
|
|
|
|
|
first.Tvdb.Episode.Should().Be(1);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|