1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2024-12-16 11:37:58 +02:00
Sonarr/NzbDrone.Core.Test/DataAugmentationFixture/Scene/SceneMappingProxyFixture.cs

52 lines
1.6 KiB
C#
Raw Normal View History

2013-04-01 05:43:58 +03:00
using System.Net;
using FluentAssertions;
using Newtonsoft.Json;
2013-09-19 03:30:37 +03:00
using NUnit.Framework;
2013-04-01 05:43:58 +03:00
using NzbDrone.Common;
using NzbDrone.Core.DataAugmentation.Scene;
using NzbDrone.Core.Test.Framework;
namespace NzbDrone.Core.Test.DataAugmentationFixture.Scene
{
[TestFixture]
public class SceneMappingProxyFixture : CoreTest<SceneMappingProxy>
{
2013-09-06 09:28:52 +03:00
private const string SCENE_MAPPING_URL = "http://services.nzbdrone.com/v1/SceneMapping";
2013-04-01 05:43:58 +03:00
[Test]
public void fetch_should_return_list_of_mappings()
{
2013-04-11 02:41:45 +03:00
Mocker.GetMock<IHttpProvider>()
2013-04-01 05:43:58 +03:00
.Setup(s => s.DownloadString(SCENE_MAPPING_URL))
.Returns(ReadAllText("Files", "SceneMappings.json"));
var mappings = Subject.Fetch();
mappings.Should().NotBeEmpty();
mappings.Should().NotContain(c => string.IsNullOrWhiteSpace(c.SearchTerm));
mappings.Should().NotContain(c => string.IsNullOrWhiteSpace(c.ParseTerm));
2013-04-01 05:43:58 +03:00
mappings.Should().NotContain(c => c.TvdbId == 0);
}
[Test]
public void should_throw_on_server_error()
{
2013-04-11 02:41:45 +03:00
Mocker.GetMock<IHttpProvider>()
2013-04-01 05:43:58 +03:00
.Setup(s => s.DownloadString(SCENE_MAPPING_URL))
.Throws(new WebException());
Assert.Throws<WebException>(() => Subject.Fetch());
}
[Test]
public void should_throw_on_bad_json()
{
2013-04-11 02:41:45 +03:00
Mocker.GetMock<IHttpProvider>()
2013-04-01 05:43:58 +03:00
.Setup(s => s.DownloadString(SCENE_MAPPING_URL))
.Returns("bad json");
Assert.Throws<JsonReaderException>(() => Subject.Fetch());
}
}
}