1
0
Fork 0
mirror of https://github.com/Sonarr/Sonarr synced 2024-12-30 19:56:54 +00:00
Sonarr/NzbDrone.Core.Test/DecisionEngineTests/MonitoredEpisodeSpecificationFixture.cs

112 lines
3.4 KiB
C#
Raw Normal View History

2013-04-15 03:33:03 +00:00
using System.Collections.Generic;
using FizzWare.NBuilder;
using FluentAssertions;
using NUnit.Framework;
using NzbDrone.Core.DecisionEngine.Specifications;
using NzbDrone.Core.Parser.Model;
using NzbDrone.Core.Tv;
using NzbDrone.Core.Test.Framework;
2013-02-19 02:19:38 +00:00
namespace NzbDrone.Core.Test.DecisionEngineTests
{
[TestFixture]
public class MonitoredEpisodeSpecificationFixture : CoreTest<MonitoredEpisodeSpecification>
{
2013-04-15 03:33:03 +00:00
private MonitoredEpisodeSpecification _monitoredEpisodeSpecification;
2013-04-15 03:33:03 +00:00
private RemoteEpisode _parseResultMulti;
private RemoteEpisode _parseResultSingle;
private Series _fakeSeries;
private Episode _firstEpisode;
private Episode _secondEpisode;
[SetUp]
public void Setup()
{
2013-04-15 03:33:03 +00:00
_monitoredEpisodeSpecification = Mocker.Resolve<MonitoredEpisodeSpecification>();
2013-04-15 03:33:03 +00:00
_fakeSeries = Builder<Series>.CreateNew()
.With(c => c.Monitored = true)
.Build();
_firstEpisode = new Episode { Monitored = true };
_secondEpisode = new Episode { Monitored = true };
2013-04-15 03:33:03 +00:00
var singleEpisodeList = new List<Episode> { _firstEpisode };
var doubleEpisodeList = new List<Episode> { _firstEpisode, _secondEpisode };
_parseResultMulti = new RemoteEpisode
{
2013-04-15 03:33:03 +00:00
Series = _fakeSeries,
Episodes = doubleEpisodeList
};
2013-04-15 03:33:03 +00:00
_parseResultSingle = new RemoteEpisode
{
2013-04-15 03:33:03 +00:00
Series = _fakeSeries,
Episodes = singleEpisodeList
};
}
private void WithFirstEpisodeUnmonitored()
{
_firstEpisode.Monitored = false;
}
private void WithSecondEpisodeUnmonitored()
{
_secondEpisode.Monitored = false;
}
[Test]
public void setup_should_return_monitored_episode_should_return_true()
{
2013-04-15 03:33:03 +00:00
_monitoredEpisodeSpecification.IsSatisfiedBy(_parseResultSingle).Should().BeTrue();
_monitoredEpisodeSpecification.IsSatisfiedBy(_parseResultMulti).Should().BeTrue();
}
[Test]
public void not_monitored_series_should_be_skipped()
{
2013-04-15 03:33:03 +00:00
_fakeSeries.Monitored = false;
_monitoredEpisodeSpecification.IsSatisfiedBy(_parseResultMulti).Should().BeFalse();
}
[Test]
public void only_episode_not_monitored_should_return_false()
{
WithFirstEpisodeUnmonitored();
2013-04-15 03:33:03 +00:00
_monitoredEpisodeSpecification.IsSatisfiedBy(_parseResultSingle).Should().BeFalse();
}
[Test]
public void both_episodes_not_monitored_should_return_false()
{
WithFirstEpisodeUnmonitored();
WithSecondEpisodeUnmonitored();
2013-04-15 03:33:03 +00:00
_monitoredEpisodeSpecification.IsSatisfiedBy(_parseResultMulti).Should().BeFalse();
}
[Test]
public void only_first_episode_not_monitored_should_return_monitored()
{
WithFirstEpisodeUnmonitored();
2013-04-15 03:33:03 +00:00
_monitoredEpisodeSpecification.IsSatisfiedBy(_parseResultMulti).Should().BeTrue();
}
[Test]
public void only_second_episode_not_monitored_should_return_monitored()
{
WithSecondEpisodeUnmonitored();
2013-04-15 03:33:03 +00:00
_monitoredEpisodeSpecification.IsSatisfiedBy(_parseResultMulti).Should().BeTrue();
}
}
}