2012-10-17 08:00:28 +03:00
|
|
|
using System;
|
|
|
|
using FluentAssertions;
|
|
|
|
using Moq;
|
|
|
|
using NUnit.Framework;
|
|
|
|
using NzbDrone.Common;
|
|
|
|
using NzbDrone.Core.Providers;
|
2013-03-07 04:51:47 +03:00
|
|
|
|
2012-10-17 08:00:28 +03:00
|
|
|
using NzbDrone.Core.Test.Framework;
|
|
|
|
|
|
|
|
namespace NzbDrone.Core.Test.ProviderTests.XemCommunicationProviderTests
|
|
|
|
{
|
|
|
|
[TestFixture]
|
2013-03-29 01:07:09 +03:00
|
|
|
|
2013-02-17 08:44:06 +03:00
|
|
|
public class GetXemSeriesIdsFixture : CoreTest
|
2012-10-17 08:00:28 +03:00
|
|
|
{
|
|
|
|
private void WithFailureJson()
|
|
|
|
{
|
2013-04-11 02:41:45 +03:00
|
|
|
Mocker.GetMock<IHttpProvider>().Setup(s => s.DownloadString(It.IsAny<String>()))
|
2013-03-28 22:05:43 +03:00
|
|
|
.Returns(ReadAllText("Files", "Xem", "Failure.txt"));
|
2012-10-17 08:00:28 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
private void WithIdsJson()
|
|
|
|
{
|
2013-04-11 02:41:45 +03:00
|
|
|
Mocker.GetMock<IHttpProvider>().Setup(s => s.DownloadString(It.IsAny<String>()))
|
2013-03-28 22:05:43 +03:00
|
|
|
.Returns(ReadAllText("Files", "Xem", "Ids.txt"));
|
2012-10-17 08:00:28 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
private void WithMappingsJson()
|
|
|
|
{
|
2013-04-11 02:41:45 +03:00
|
|
|
Mocker.GetMock<IHttpProvider>().Setup(s => s.DownloadString(It.IsAny<String>()))
|
2013-03-28 22:05:43 +03:00
|
|
|
.Returns(ReadAllText("Files", "Xem", "Mappings.txt"));
|
2012-10-17 08:00:28 +03: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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|