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

55 lines
1.6 KiB
C#
Raw Normal View History

2012-10-17 05:00:28 +00:00
using System;
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;
namespace NzbDrone.Core.Test.ProviderTests.XemCommunicationProviderTests
{
[TestFixture]
2013-03-28 22:07:09 +00:00
public class GetXemSeriesIdsFixture : 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>()))
.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>()))
.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>()))
.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>().GetXemSeriesIds());
}
[Test]
public void should_get_list_of_int()
{
WithIdsJson();
Mocker.Resolve<XemCommunicationProvider>().GetXemSeriesIds().Should().NotBeEmpty();
}
[Test]
public void should_have_two_ids()
{
WithIdsJson();
Mocker.Resolve<XemCommunicationProvider>().GetXemSeriesIds().Should().HaveCount(2);
}
}
}