mirror of
https://github.com/Sonarr/Sonarr.git
synced 2024-12-14 11:23:42 +02:00
fixed more tests
This commit is contained in:
parent
6e88f55a54
commit
15c15b4f71
@ -43,7 +43,7 @@ public void Setup()
|
|||||||
_fail2.Setup(c => c.IsSatisfiedBy(It.IsAny<RemoteEpisode>())).Returns(false);
|
_fail2.Setup(c => c.IsSatisfiedBy(It.IsAny<RemoteEpisode>())).Returns(false);
|
||||||
_fail3.Setup(c => c.IsSatisfiedBy(It.IsAny<RemoteEpisode>())).Returns(false);
|
_fail3.Setup(c => c.IsSatisfiedBy(It.IsAny<RemoteEpisode>())).Returns(false);
|
||||||
|
|
||||||
_reports = new List<ReportInfo>();
|
_reports = new List<ReportInfo> {new ReportInfo()};
|
||||||
_remoteEpisode = new RemoteEpisode();
|
_remoteEpisode = new RemoteEpisode();
|
||||||
|
|
||||||
Mocker.GetMock<IParsingService>().Setup(c => c.Map(It.IsAny<ReportInfo>()))
|
Mocker.GetMock<IParsingService>().Setup(c => c.Map(It.IsAny<ReportInfo>()))
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
using System;
|
using System.Collections.Generic;
|
||||||
using System.Collections.Generic;
|
|
||||||
using FizzWare.NBuilder;
|
using FizzWare.NBuilder;
|
||||||
using FluentAssertions;
|
using FluentAssertions;
|
||||||
using Moq;
|
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using NzbDrone.Core.DecisionEngine.Specifications;
|
using NzbDrone.Core.DecisionEngine.Specifications;
|
||||||
using NzbDrone.Core.Parser.Model;
|
using NzbDrone.Core.Parser.Model;
|
||||||
@ -15,79 +13,70 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
|||||||
|
|
||||||
public class MonitoredEpisodeSpecificationFixture : CoreTest<MonitoredEpisodeSpecification>
|
public class MonitoredEpisodeSpecificationFixture : CoreTest<MonitoredEpisodeSpecification>
|
||||||
{
|
{
|
||||||
private MonitoredEpisodeSpecification monitoredEpisodeSpecification;
|
private MonitoredEpisodeSpecification _monitoredEpisodeSpecification;
|
||||||
|
|
||||||
private RemoteEpisode parseResultMulti;
|
private RemoteEpisode _parseResultMulti;
|
||||||
private RemoteEpisode parseResultSingle;
|
private RemoteEpisode _parseResultSingle;
|
||||||
private Series fakeSeries;
|
private Series _fakeSeries;
|
||||||
private Episode firstEpisode;
|
private Episode _firstEpisode;
|
||||||
private Episode secondEpisode;
|
private Episode _secondEpisode;
|
||||||
|
|
||||||
[SetUp]
|
[SetUp]
|
||||||
public void Setup()
|
public void Setup()
|
||||||
{
|
{
|
||||||
monitoredEpisodeSpecification = Mocker.Resolve<MonitoredEpisodeSpecification>();
|
_monitoredEpisodeSpecification = Mocker.Resolve<MonitoredEpisodeSpecification>();
|
||||||
|
|
||||||
fakeSeries = Builder<Series>.CreateNew()
|
_fakeSeries = Builder<Series>.CreateNew()
|
||||||
.With(c => c.Monitored = true)
|
.With(c => c.Monitored = true)
|
||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
|
_firstEpisode = new Episode { Ignored = false };
|
||||||
|
_secondEpisode = new Episode { Ignored = false };
|
||||||
|
|
||||||
var singleEpisodeList = new List<Episode> { firstEpisode };
|
|
||||||
var doubleEpisodeList = new List<Episode> { firstEpisode, secondEpisode };
|
|
||||||
|
|
||||||
parseResultMulti = new RemoteEpisode
|
var singleEpisodeList = new List<Episode> { _firstEpisode };
|
||||||
|
var doubleEpisodeList = new List<Episode> { _firstEpisode, _secondEpisode };
|
||||||
|
|
||||||
|
_parseResultMulti = new RemoteEpisode
|
||||||
{
|
{
|
||||||
Series = fakeSeries,
|
Series = _fakeSeries,
|
||||||
Episodes = doubleEpisodeList
|
Episodes = doubleEpisodeList
|
||||||
};
|
};
|
||||||
|
|
||||||
parseResultSingle = new RemoteEpisode
|
_parseResultSingle = new RemoteEpisode
|
||||||
{
|
{
|
||||||
Series = fakeSeries,
|
Series = _fakeSeries,
|
||||||
Episodes = singleEpisodeList
|
Episodes = singleEpisodeList
|
||||||
};
|
};
|
||||||
|
|
||||||
firstEpisode = new Episode { Ignored = false };
|
|
||||||
secondEpisode = new Episode { Ignored = false };
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void WithFirstEpisodeIgnored()
|
private void WithFirstEpisodeIgnored()
|
||||||
{
|
{
|
||||||
firstEpisode.Ignored = true;
|
_firstEpisode.Ignored = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void WithSecondEpisodeIgnored()
|
private void WithSecondEpisodeIgnored()
|
||||||
{
|
{
|
||||||
secondEpisode.Ignored = true;
|
_secondEpisode.Ignored = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void setup_should_return_monitored_episode_should_return_true()
|
public void setup_should_return_monitored_episode_should_return_true()
|
||||||
{
|
{
|
||||||
monitoredEpisodeSpecification.IsSatisfiedBy(parseResultSingle).Should().BeTrue();
|
_monitoredEpisodeSpecification.IsSatisfiedBy(_parseResultSingle).Should().BeTrue();
|
||||||
monitoredEpisodeSpecification.IsSatisfiedBy(parseResultMulti).Should().BeTrue();
|
_monitoredEpisodeSpecification.IsSatisfiedBy(_parseResultMulti).Should().BeTrue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void not_monitored_series_should_be_skipped()
|
public void not_monitored_series_should_be_skipped()
|
||||||
{
|
{
|
||||||
fakeSeries.Monitored = false;
|
_fakeSeries.Monitored = false;
|
||||||
monitoredEpisodeSpecification.IsSatisfiedBy(parseResultMulti).Should().BeFalse();
|
_monitoredEpisodeSpecification.IsSatisfiedBy(_parseResultMulti).Should().BeFalse();
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
[Test]
|
|
||||||
public void not_in_db_should_be_skipped()
|
|
||||||
{
|
|
||||||
Mocker.GetMock<ISeriesRepository>()
|
|
||||||
.Setup(p => p.FindByTitle(It.IsAny<String>()))
|
|
||||||
.Returns<Series>(null);
|
|
||||||
|
|
||||||
monitoredEpisodeSpecification.IsSatisfiedBy(parseResultMulti).Should().BeFalse();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -95,7 +84,7 @@ public void not_in_db_should_be_skipped()
|
|||||||
public void only_episode_ignored_should_return_false()
|
public void only_episode_ignored_should_return_false()
|
||||||
{
|
{
|
||||||
WithFirstEpisodeIgnored();
|
WithFirstEpisodeIgnored();
|
||||||
monitoredEpisodeSpecification.IsSatisfiedBy(parseResultSingle).Should().BeFalse();
|
_monitoredEpisodeSpecification.IsSatisfiedBy(_parseResultSingle).Should().BeFalse();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -104,7 +93,7 @@ public void both_episodes_ignored_should_return_false()
|
|||||||
{
|
{
|
||||||
WithFirstEpisodeIgnored();
|
WithFirstEpisodeIgnored();
|
||||||
WithSecondEpisodeIgnored();
|
WithSecondEpisodeIgnored();
|
||||||
monitoredEpisodeSpecification.IsSatisfiedBy(parseResultMulti).Should().BeFalse();
|
_monitoredEpisodeSpecification.IsSatisfiedBy(_parseResultMulti).Should().BeFalse();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -112,7 +101,7 @@ public void both_episodes_ignored_should_return_false()
|
|||||||
public void only_first_episode_ignored_should_return_monitored()
|
public void only_first_episode_ignored_should_return_monitored()
|
||||||
{
|
{
|
||||||
WithFirstEpisodeIgnored();
|
WithFirstEpisodeIgnored();
|
||||||
monitoredEpisodeSpecification.IsSatisfiedBy(parseResultMulti).Should().BeTrue();
|
_monitoredEpisodeSpecification.IsSatisfiedBy(_parseResultMulti).Should().BeTrue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -120,7 +109,7 @@ public void only_first_episode_ignored_should_return_monitored()
|
|||||||
public void only_second_episode_ignored_should_return_monitored()
|
public void only_second_episode_ignored_should_return_monitored()
|
||||||
{
|
{
|
||||||
WithSecondEpisodeIgnored();
|
WithSecondEpisodeIgnored();
|
||||||
monitoredEpisodeSpecification.IsSatisfiedBy(parseResultMulti).Should().BeTrue();
|
_monitoredEpisodeSpecification.IsSatisfiedBy(_parseResultMulti).Should().BeTrue();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user