sonarr-repo-only/NzbDrone.Core.Test/ProviderTests/XemCommunicationProviderTests/GetSceneTvdbMappingsFixture.cs

71 lines
2.2 KiB
C#
Raw Normal View History

2012-10-17 05:00:28 +00:00
using System;
using System.Linq;
using FluentAssertions;
using Moq;
using NUnit.Framework;
using NzbDrone.Common;
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;
2013-09-17 06:14:47 +00:00
using NzbDrone.Test.Common.Categories;
2012-10-17 05:00:28 +00:00
namespace NzbDrone.Core.Test.ProviderTests.XemCommunicationProviderTests
{
[TestFixture]
2013-09-17 06:14:47 +00:00
[IntegrationTest]
public class GetSceneTvdbMappingsFixture : CoreTest
2012-10-17 05:00:28 +00:00
{
private void WithFailureJson()
{
2013-04-10 23:41:45 +00:00
Mocker.GetMock<IHttpProvider>().Setup(s => s.DownloadString(It.IsAny<String>()))
2013-09-17 06:14:47 +00:00
.Returns(ReadAllText("Files", "Xem", "Failure.txt"));
2012-10-17 05:00:28 +00:00
}
private void WithIdsJson()
{
2013-04-10 23:41:45 +00:00
Mocker.GetMock<IHttpProvider>().Setup(s => s.DownloadString(It.IsAny<String>()))
2013-09-17 06:14:47 +00:00
.Returns(ReadAllText("Files", "Xem", "Ids.txt"));
2012-10-17 05:00:28 +00:00
}
private void WithMappingsJson()
{
2013-04-10 23:41:45 +00:00
Mocker.GetMock<IHttpProvider>().Setup(s => s.DownloadString(It.IsAny<String>()))
2013-09-17 06:14:47 +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();
2013-09-17 06:14:47 +00:00
Assert.Throws<Exception>(() => Mocker.Resolve<XemProxy>().GetSceneTvdbMappings(12345));
2012-10-17 05:00:28 +00:00
}
[Test]
public void should_get_list_of_mappings()
{
WithMappingsJson();
2013-09-17 06:14:47 +00:00
Mocker.Resolve<XemProxy>().GetSceneTvdbMappings(12345).Should().NotBeEmpty();
2012-10-17 05:00:28 +00:00
}
[Test]
public void should_have_two_mappings()
{
WithMappingsJson();
2013-09-17 06:14:47 +00:00
Mocker.Resolve<XemProxy>().GetSceneTvdbMappings(12345).Should().HaveCount(2);
2012-10-17 05:00:28 +00:00
}
[Test]
public void should_have_expected_results()
{
WithMappingsJson();
2013-09-17 06:14:47 +00:00
var results = Mocker.Resolve<XemProxy>().GetSceneTvdbMappings(12345);
2012-10-17 05:00:28 +00:00
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);
}
}
}