1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2024-12-18 23:48:35 +02:00
Sonarr/NzbDrone.Core.Test/ProviderTests/TvRageProviderTests/SearchSeriesFixture.cs

80 lines
2.7 KiB
C#
Raw Normal View History

2012-12-18 09:41:08 +03:00
// ReSharper disable RedundantUsingDirective
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using FluentAssertions;
using Moq;
using NUnit.Framework;
using NzbDrone.Common;
using NzbDrone.Core.MetadataSource;
2012-12-18 09:41:08 +03:00
using NzbDrone.Core.Providers;
using NzbDrone.Core.Test.Framework;
using NzbDrone.Test.Common;
namespace NzbDrone.Core.Test.ProviderTests.TvRageProviderTests
{
[TestFixture]
// ReSharper disable InconsistentNaming
public class SearchSeriesFixture : CoreTest
2012-12-18 09:41:08 +03:00
{
private const string search = "http://services.tvrage.com/feeds/full_search.php?show=";
private void WithEmptyResults()
{
Mocker.GetMock<HttpProvider>()
.Setup(s => s.DownloadStream(It.Is<String>(u => u.StartsWith(search)), null))
.Returns(new FileStream(@".\Files\TVRage\SearchResults_empty.xml", FileMode.Open, FileAccess.Read, FileShare.Read));
}
private void WithManyResults()
{
Mocker.GetMock<HttpProvider>()
.Setup(s => s.DownloadStream(It.Is<String>(u => u.StartsWith(search)), null))
.Returns(new FileStream(@".\Files\TVRage\SearchResults_many.xml", FileMode.Open, FileAccess.Read, FileShare.Read));
}
private void WithOneResult()
{
Mocker.GetMock<HttpProvider>()
.Setup(s => s.DownloadStream(It.Is<String>(u => u.StartsWith(search)), null))
.Returns(new FileStream(@".\Files\TVRage\SearchResults_one.xml", FileMode.Open, FileAccess.Read, FileShare.Read));
}
[Test]
public void should_be_empty_when_no_results_are_found()
{
WithEmptyResults();
Mocker.Resolve<TvRageProxy>().SearchSeries("asdasdasdasdas").Should().BeEmpty();
2012-12-18 09:41:08 +03:00
}
[Test]
public void should_be_have_more_than_one_when_multiple_results_are_returned()
{
WithManyResults();
Mocker.Resolve<TvRageProxy>().SearchSeries("top+gear").Should().NotBeEmpty();
2012-12-18 09:41:08 +03:00
}
[Test]
public void should_have_one_when_only_one_result_is_found()
{
WithOneResult();
Mocker.Resolve<TvRageProxy>().SearchSeries("suits").Should().HaveCount(1);
2012-12-18 09:41:08 +03:00
}
[Test]
public void ended_should_not_have_a_value_when_series_has_not_ended()
{
WithOneResult();
Mocker.Resolve<TvRageProxy>().SearchSeries("suits").First().Ended.HasValue.Should().BeFalse();
2012-12-18 09:41:08 +03:00
}
[Test]
public void started_should_match_series()
{
WithOneResult();
Mocker.Resolve<TvRageProxy>().SearchSeries("suits").First().Started.Should().Be(new DateTime(2011, 6, 23));
2012-12-18 09:41:08 +03:00
}
}
}