1
0
mirror of https://github.com/Radarr/Radarr.git synced 2026-04-25 22:37:27 -04:00

Reformat and apply Stylecop rules

This commit is contained in:
ta264
2019-12-22 22:08:53 +00:00
committed by Qstick
parent d4fa9b7345
commit f02fa629cc
1186 changed files with 7105 additions and 5616 deletions
@@ -4,10 +4,10 @@ using FluentAssertions;
using Moq;
using NUnit.Framework;
using NzbDrone.Core.DecisionEngine.Specifications;
using NzbDrone.Core.Movies;
using NzbDrone.Core.Parser.Model;
using NzbDrone.Core.Qualities;
using NzbDrone.Core.Test.Framework;
using NzbDrone.Core.Movies;
using NzbDrone.Test.Common;
namespace NzbDrone.Core.Test.DecisionEngineTests
@@ -16,40 +16,35 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
public class AcceptableSizeSpecificationFixture : CoreTest<AcceptableSizeSpecification>
{
private Movie movie;
private RemoteMovie remoteMovie;
private QualityDefinition qualityType;
private Movie _movie;
private RemoteMovie _remoteMovie;
private QualityDefinition _qualityType;
[SetUp]
public void Setup()
{
_movie = Builder<Movie>.CreateNew().Build();
movie = Builder<Movie>.CreateNew().Build();
qualityType = Builder<QualityDefinition>.CreateNew()
_qualityType = Builder<QualityDefinition>.CreateNew()
.With(q => q.MinSize = 2)
.With(q => q.MaxSize = 10)
.With(q => q.Quality = Quality.SDTV)
.Build();
remoteMovie = new RemoteMovie
_remoteMovie = new RemoteMovie
{
Movie = movie,
Movie = _movie,
Release = new ReleaseInfo(),
ParsedMovieInfo = new ParsedMovieInfo { Quality = new QualityModel(Quality.SDTV, new Revision(version: 2)) },
};
Mocker.GetMock<IQualityDefinitionService>()
.Setup(v => v.Get(It.IsAny<Quality>()))
.Returns<Quality>(v => Quality.DefaultQualityDefinitions.First(c => c.Quality == v));
Mocker.GetMock<IQualityDefinitionService>().Setup(s => s.Get(Quality.SDTV)).Returns(qualityType);
Mocker.GetMock<IQualityDefinitionService>().Setup(s => s.Get(Quality.SDTV)).Returns(_qualityType);
}
[TestCase(30, 50, false)]
[TestCase(30, 250, true)]
[TestCase(30, 500, false)]
@@ -58,57 +53,57 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
[TestCase(60, 1000, false)]
public void single_episode(int runtime, int sizeInMegaBytes, bool expectedResult)
{
movie.Runtime = runtime;
remoteMovie.Movie = movie;
remoteMovie.Release.Size = sizeInMegaBytes.Megabytes();
_movie.Runtime = runtime;
_remoteMovie.Movie = _movie;
_remoteMovie.Release.Size = sizeInMegaBytes.Megabytes();
Subject.IsSatisfiedBy(remoteMovie, null).Accepted.Should().Be(expectedResult);
Subject.IsSatisfiedBy(_remoteMovie, null).Accepted.Should().Be(expectedResult);
}
[Test]
public void should_return_true_if_size_is_zero()
{
movie.Runtime = 120;
remoteMovie.Movie = movie;
remoteMovie.Release.Size = 0;
qualityType.MinSize = 10;
qualityType.MaxSize = 20;
_movie.Runtime = 120;
_remoteMovie.Movie = _movie;
_remoteMovie.Release.Size = 0;
_qualityType.MinSize = 10;
_qualityType.MaxSize = 20;
Subject.IsSatisfiedBy(remoteMovie, null).Accepted.Should().BeTrue();
Subject.IsSatisfiedBy(_remoteMovie, null).Accepted.Should().BeTrue();
}
[Test]
public void should_return_true_if_unlimited_30_minute()
{
movie.Runtime = 30;
remoteMovie.Movie = movie;
remoteMovie.Release.Size = 18457280000;
qualityType.MaxSize = null;
_movie.Runtime = 30;
_remoteMovie.Movie = _movie;
_remoteMovie.Release.Size = 18457280000;
_qualityType.MaxSize = null;
Subject.IsSatisfiedBy(remoteMovie, null).Accepted.Should().BeTrue();
Subject.IsSatisfiedBy(_remoteMovie, null).Accepted.Should().BeTrue();
}
[Test]
public void should_return_true_if_unlimited_60_minute()
{
movie.Runtime = 60;
remoteMovie.Movie = movie;
remoteMovie.Release.Size = 36857280000;
qualityType.MaxSize = null;
_movie.Runtime = 60;
_remoteMovie.Movie = _movie;
_remoteMovie.Release.Size = 36857280000;
_qualityType.MaxSize = null;
Subject.IsSatisfiedBy(remoteMovie, null).Accepted.Should().BeTrue();
Subject.IsSatisfiedBy(_remoteMovie, null).Accepted.Should().BeTrue();
}
[Test]
public void should_use_110_minutes_if_runtime_is_0()
{
movie.Runtime = 0;
remoteMovie.Movie = movie;
remoteMovie.Release.Size = 1095.Megabytes();
_movie.Runtime = 0;
_remoteMovie.Movie = _movie;
_remoteMovie.Release.Size = 1095.Megabytes();
Subject.IsSatisfiedBy(remoteMovie, null).Accepted.Should().Be(true);
remoteMovie.Release.Size = 1105.Megabytes();
Subject.IsSatisfiedBy(remoteMovie, null).Accepted.Should().Be(false);
Subject.IsSatisfiedBy(_remoteMovie, null).Accepted.Should().Be(true);
_remoteMovie.Release.Size = 1105.Megabytes();
Subject.IsSatisfiedBy(_remoteMovie, null).Accepted.Should().Be(false);
ExceptionVerification.ExpectedWarns(1);
}
}
@@ -4,10 +4,10 @@ using FluentAssertions;
using Marr.Data;
using NUnit.Framework;
using NzbDrone.Core.DecisionEngine.Specifications;
using NzbDrone.Core.Movies;
using NzbDrone.Core.Parser.Model;
using NzbDrone.Core.Profiles;
using NzbDrone.Core.Qualities;
using NzbDrone.Core.Movies;
using NzbDrone.Core.Test.CustomFormat;
using NzbDrone.Core.Test.Framework;
@@ -17,7 +17,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
public class CustomFormatAllowedByProfileSpecificationFixture : CoreTest<CustomFormatAllowedbyProfileSpecification>
{
private RemoteMovie remoteMovie;
private RemoteMovie _remoteMovie;
private CustomFormats.CustomFormat _format1;
private CustomFormats.CustomFormat _format2;
@@ -31,12 +31,11 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
_format2 = new CustomFormats.CustomFormat("Cool Format");
_format2.Id = 2;
var fakeSeries = Builder<Movie>.CreateNew()
.With(c => c.Profile = (LazyLoaded<Profile>)new Profile { Cutoff = Quality.Bluray1080p.Id })
.Build();
remoteMovie = new RemoteMovie
_remoteMovie = new RemoteMovie
{
Movie = fakeSeries,
ParsedMovieInfo = new ParsedMovieInfo { Quality = new QualityModel(Quality.DVD, new Revision(version: 2)) },
@@ -48,55 +47,55 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
[Test]
public void should_allow_if_format_is_defined_in_profile()
{
remoteMovie.ParsedMovieInfo.Quality.CustomFormats = new List<CustomFormats.CustomFormat> {_format1};
remoteMovie.Movie.Profile.Value.FormatItems = CustomFormatsFixture.GetSampleFormatItems(_format1.Name);
_remoteMovie.ParsedMovieInfo.Quality.CustomFormats = new List<CustomFormats.CustomFormat> { _format1 };
_remoteMovie.Movie.Profile.Value.FormatItems = CustomFormatsFixture.GetSampleFormatItems(_format1.Name);
Subject.IsSatisfiedBy(remoteMovie, null).Accepted.Should().BeTrue();
Subject.IsSatisfiedBy(_remoteMovie, null).Accepted.Should().BeTrue();
}
[Test]
public void should_deny_if_format_is_defined_in_profile()
{
remoteMovie.ParsedMovieInfo.Quality.CustomFormats = new List<CustomFormats.CustomFormat> {_format2};
remoteMovie.Movie.Profile.Value.FormatItems = CustomFormatsFixture.GetSampleFormatItems(_format1.Name);
_remoteMovie.ParsedMovieInfo.Quality.CustomFormats = new List<CustomFormats.CustomFormat> { _format2 };
_remoteMovie.Movie.Profile.Value.FormatItems = CustomFormatsFixture.GetSampleFormatItems(_format1.Name);
Subject.IsSatisfiedBy(remoteMovie, null).Accepted.Should().BeFalse();
Subject.IsSatisfiedBy(_remoteMovie, null).Accepted.Should().BeFalse();
}
[Test]
public void should_deny_if_one_format_is_defined_in_profile()
{
remoteMovie.ParsedMovieInfo.Quality.CustomFormats = new List<CustomFormats.CustomFormat> {_format2, _format1};
remoteMovie.Movie.Profile.Value.FormatItems = CustomFormatsFixture.GetSampleFormatItems(_format1.Name);
_remoteMovie.ParsedMovieInfo.Quality.CustomFormats = new List<CustomFormats.CustomFormat> { _format2, _format1 };
_remoteMovie.Movie.Profile.Value.FormatItems = CustomFormatsFixture.GetSampleFormatItems(_format1.Name);
Subject.IsSatisfiedBy(remoteMovie, null).Accepted.Should().BeFalse();
Subject.IsSatisfiedBy(_remoteMovie, null).Accepted.Should().BeFalse();
}
[Test]
public void should_allow_if_all_format_is_defined_in_profile()
{
remoteMovie.ParsedMovieInfo.Quality.CustomFormats = new List<CustomFormats.CustomFormat> {_format2, _format1};
remoteMovie.Movie.Profile.Value.FormatItems = CustomFormatsFixture.GetSampleFormatItems(_format1.Name, _format2.Name);
_remoteMovie.ParsedMovieInfo.Quality.CustomFormats = new List<CustomFormats.CustomFormat> { _format2, _format1 };
_remoteMovie.Movie.Profile.Value.FormatItems = CustomFormatsFixture.GetSampleFormatItems(_format1.Name, _format2.Name);
Subject.IsSatisfiedBy(remoteMovie, null).Accepted.Should().BeTrue();
Subject.IsSatisfiedBy(_remoteMovie, null).Accepted.Should().BeTrue();
}
[Test]
public void should_deny_if_no_format_was_parsed_and_none_not_in_profile()
{
remoteMovie.ParsedMovieInfo.Quality.CustomFormats = new List<CustomFormats.CustomFormat> {};
remoteMovie.Movie.Profile.Value.FormatItems = CustomFormatsFixture.GetSampleFormatItems(_format1.Name, _format2.Name);
_remoteMovie.ParsedMovieInfo.Quality.CustomFormats = new List<CustomFormats.CustomFormat> { };
_remoteMovie.Movie.Profile.Value.FormatItems = CustomFormatsFixture.GetSampleFormatItems(_format1.Name, _format2.Name);
Subject.IsSatisfiedBy(remoteMovie, null).Accepted.Should().BeFalse();
Subject.IsSatisfiedBy(_remoteMovie, null).Accepted.Should().BeFalse();
}
[Test]
public void should_allow_if_no_format_was_parsed_and_none_in_profile()
{
remoteMovie.ParsedMovieInfo.Quality.CustomFormats = new List<CustomFormats.CustomFormat> {};
remoteMovie.Movie.Profile.Value.FormatItems = CustomFormatsFixture.GetSampleFormatItems(CustomFormats.CustomFormat.None.Name, _format1.Name, _format2.Name);
_remoteMovie.ParsedMovieInfo.Quality.CustomFormats = new List<CustomFormats.CustomFormat> { };
_remoteMovie.Movie.Profile.Value.FormatItems = CustomFormatsFixture.GetSampleFormatItems(CustomFormats.CustomFormat.None.Name, _format1.Name, _format2.Name);
Subject.IsSatisfiedBy(remoteMovie, null).Accepted.Should().BeTrue();
Subject.IsSatisfiedBy(_remoteMovie, null).Accepted.Should().BeTrue();
}
}
}
@@ -1,29 +1,27 @@
using System.Collections.Generic;
using FluentAssertions;
using NUnit.Framework;
using NzbDrone.Core.DecisionEngine.Specifications;
using NzbDrone.Core.Profiles;
using NzbDrone.Core.Qualities;
using NzbDrone.Core.DecisionEngine.Specifications;
using NzbDrone.Core.Test.Framework;
using NzbDrone.Core.Test.CustomFormat;
using NzbDrone.Core.Test.Framework;
namespace NzbDrone.Core.Test.DecisionEngineTests
{
[TestFixture]
public class CutoffSpecificationFixture : CoreTest<UpgradableSpecification>
{
private CustomFormats.CustomFormat _customFormat;
[SetUp]
public void Setup()
{
}
private void GivenCustomFormatHigher()
{
_customFormat = new CustomFormats.CustomFormat("My Format", "L_ENGLISH") {Id = 1};
_customFormat = new CustomFormats.CustomFormat("My Format", "L_ENGLISH") { Id = 1 };
CustomFormatsFixture.GivenCustomFormats(_customFormat, CustomFormats.CustomFormat.None);
}
@@ -70,9 +68,9 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
{
GivenCustomFormatHigher();
var old = new QualityModel(Quality.HDTV720p);
old.CustomFormats = new List<CustomFormats.CustomFormat> {CustomFormats.CustomFormat.None};
old.CustomFormats = new List<CustomFormats.CustomFormat> { CustomFormats.CustomFormat.None };
var newQ = new QualityModel(Quality.Bluray1080p);
newQ.CustomFormats = new List<CustomFormats.CustomFormat> {_customFormat};
newQ.CustomFormats = new List<CustomFormats.CustomFormat> { _customFormat };
Subject.CutoffNotMet(
new Profile
{
@@ -80,20 +78,22 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
Items = Qualities.QualityFixture.GetDefaultQualities(),
FormatCutoff = CustomFormats.CustomFormat.None.Id,
FormatItems = CustomFormatsFixture.GetSampleFormatItems("None", "My Format")
}, old, newQ).Should().BeFalse();
},
old,
newQ).Should().BeFalse();
}
[Test]
public void should_return_true_if_cutoffs_are_met_but_is_a_revision_upgrade()
{
Profile _profile = new Profile
Profile profile = new Profile
{
Cutoff = Quality.HDTV1080p.Id,
Items = Qualities.QualityFixture.GetDefaultQualities(),
};
Subject.CutoffNotMet(
_profile,
profile,
new QualityModel(Quality.WEBDL1080p, new Revision(version: 1)),
new QualityModel(Quality.WEBDL1080p, new Revision(version: 2))).Should().BeTrue();
}
@@ -4,13 +4,13 @@ using FluentAssertions;
using Moq;
using NUnit.Framework;
using NzbDrone.Core.DecisionEngine;
using NzbDrone.Core.DecisionEngine.Specifications;
using NzbDrone.Core.IndexerSearch.Definitions;
using NzbDrone.Core.Movies;
using NzbDrone.Core.Parser;
using NzbDrone.Core.Parser.Model;
using NzbDrone.Core.Test.Framework;
using NzbDrone.Core.Movies;
using NzbDrone.Test.Common;
using NzbDrone.Core.DecisionEngine.Specifications;
namespace NzbDrone.Core.Test.DecisionEngineTests
{
@@ -51,15 +51,15 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
_fail3.Setup(c => c.IsSatisfiedBy(It.IsAny<RemoteMovie>(), null)).Returns(Decision.Reject("fail3"));
_reports = new List<ReleaseInfo> { new ReleaseInfo { Title = "Trolls.2016.720p.WEB-DL.DD5.1.H264-FGT" } };
_remoteEpisode = new RemoteMovie {
_remoteEpisode = new RemoteMovie
{
Movie = new Movie(),
ParsedMovieInfo = new ParsedMovieInfo()
};
_mappingResult = new MappingResult {Movie = new Movie(), MappingResultType = MappingResultType.Success};
_mappingResult = new MappingResult { Movie = new Movie(), MappingResultType = MappingResultType.Success };
_mappingResult.RemoteMovie = _remoteEpisode;
Mocker.GetMock<IParsingService>()
.Setup(c => c.Map(It.IsAny<ParsedMovieInfo>(), It.IsAny<string>(), It.IsAny<SearchCriteriaBase>())).Returns(_mappingResult);
}
@@ -184,9 +184,9 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
_reports = new List<ReleaseInfo>
{
new ReleaseInfo{Title = "Trolls.2016.720p.WEB-DL.DD5.1.H264-FGT"},
new ReleaseInfo{Title = "Trolls.2016.720p.WEB-DL.DD5.1.H264-FGT"},
new ReleaseInfo{Title = "Trolls.2016.720p.WEB-DL.DD5.1.H264-FGT"}
new ReleaseInfo { Title = "Trolls.2016.720p.WEB-DL.DD5.1.H264-FGT" },
new ReleaseInfo { Title = "Trolls.2016.720p.WEB-DL.DD5.1.H264-FGT" },
new ReleaseInfo { Title = "Trolls.2016.720p.WEB-DL.DD5.1.H264-FGT" }
};
Subject.GetRssDecision(_reports);
@@ -248,7 +248,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
_reports = new List<ReleaseInfo>
{
new ReleaseInfo{Title = "Trolls.2016.720p.WEB-DL.DD5.1.H264-FGT"},
new ReleaseInfo { Title = "Trolls.2016.720p.WEB-DL.DD5.1.H264-FGT" },
};
Subject.GetRssDecision(_reports).Should().HaveCount(1);
@@ -4,29 +4,30 @@ using FluentAssertions;
using Moq;
using NUnit.Framework;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.DecisionEngine.Specifications;
using NzbDrone.Core.DecisionEngine.Specifications.RssSync;
using NzbDrone.Core.History;
using NzbDrone.Core.IndexerSearch.Definitions;
using NzbDrone.Core.Movies;
using NzbDrone.Core.Parser.Model;
using NzbDrone.Core.Profiles;
using NzbDrone.Core.Qualities;
using NzbDrone.Core.Movies;
using NzbDrone.Core.Test.Framework;
using NzbDrone.Core.DecisionEngine.Specifications;
namespace NzbDrone.Core.Test.DecisionEngineTests
{
[TestFixture]
public class HistorySpecificationFixture : CoreTest<HistorySpecification>
{
private const int FIRST_EPISODE_ID = 1;
private const int SECOND_EPISODE_ID = 2;
private HistorySpecification _upgradeHistory;
private RemoteMovie _parseResultSingle;
private QualityModel _upgradableQuality;
private QualityModel _notupgradableQuality;
private Movie _fakeMovie;
private const int FIRST_EPISODE_ID = 1;
private const int SECOND_EPISODE_ID = 2;
[SetUp]
public void Setup()
@@ -85,13 +86,12 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
_upgradeHistory.IsSatisfiedBy(_parseResultSingle, null).Accepted.Should().BeTrue();
}
// [Test]
// public void should_return_true_if_latest_history_has_a_download_id_and_cdh_is_enabled()
// {
// GivenMostRecentForEpisode(FIRST_EPISODE_ID, "test", _notupgradableQuality, DateTime.UtcNow, HistoryEventType.Grabbed);
// _upgradeHistory.IsSatisfiedBy(_parseResultMulti, null).Accepted.Should().BeTrue();
// }
// [Test]
// public void should_return_true_if_latest_history_has_a_download_id_and_cdh_is_enabled()
// {
// GivenMostRecentForEpisode(FIRST_EPISODE_ID, "test", _notupgradableQuality, DateTime.UtcNow, HistoryEventType.Grabbed);
// _upgradeHistory.IsSatisfiedBy(_parseResultMulti, null).Accepted.Should().BeTrue();
// }
[Test]
public void should_return_true_if_latest_history_item_is_older_than_twelve_hours()
{
@@ -3,11 +3,11 @@ using FluentAssertions;
using Marr.Data;
using NUnit.Framework;
using NzbDrone.Core.DecisionEngine.Specifications;
using NzbDrone.Core.Languages;
using NzbDrone.Core.Movies;
using NzbDrone.Core.Parser.Model;
using NzbDrone.Core.Profiles;
using NzbDrone.Core.Test.Framework;
using NzbDrone.Core.Movies;
using NzbDrone.Core.Languages;
namespace NzbDrone.Core.Test.DecisionEngineTests
{
@@ -24,26 +24,26 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
{
ParsedMovieInfo = new ParsedMovieInfo
{
Languages = new List<Language> {Language.English}
Languages = new List<Language> { Language.English }
},
Movie = new Movie
{
Profile = new LazyLoaded<Profile>(new Profile
{
Language = Language.English
})
}
{
Profile = new LazyLoaded<Profile>(new Profile
{
Language = Language.English
})
}
};
}
private void WithEnglishRelease()
{
_remoteMovie.ParsedMovieInfo.Languages = new List<Language> {Language.English};
_remoteMovie.ParsedMovieInfo.Languages = new List<Language> { Language.English };
}
private void WithGermanRelease()
{
_remoteMovie.ParsedMovieInfo.Languages = new List<Language> {Language.German};
_remoteMovie.ParsedMovieInfo.Languages = new List<Language> { Language.German };
}
[Test]
@@ -4,8 +4,8 @@ using FluentAssertions;
using NUnit.Framework;
using NzbDrone.Core.DecisionEngine.Specifications.RssSync;
using NzbDrone.Core.IndexerSearch.Definitions;
using NzbDrone.Core.Parser.Model;
using NzbDrone.Core.Movies;
using NzbDrone.Core.Parser.Model;
using NzbDrone.Core.Test.Framework;
namespace NzbDrone.Core.Test.DecisionEngineTests
@@ -34,7 +34,6 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
_firstEpisode = new Movie() { Monitored = true };
_secondEpisode = new Movie() { Monitored = true };
var singleEpisodeList = new List<Movie> { _firstEpisode };
var doubleEpisodeList = new List<Movie> { _firstEpisode, _secondEpisode };
@@ -79,8 +78,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
public void should_return_true_for_single_episode_search()
{
_fakeSeries.Monitored = false;
_monitoredEpisodeSpecification.IsSatisfiedBy(_parseResultSingle, new MovieSearchCriteria {UserInvokedSearch = true}).Accepted.Should().BeTrue();
_monitoredEpisodeSpecification.IsSatisfiedBy(_parseResultSingle, new MovieSearchCriteria { UserInvokedSearch = true }).Accepted.Should().BeTrue();
}
}
}
@@ -1,24 +1,25 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Moq;
using NzbDrone.Core.Indexers;
using NzbDrone.Core.Profiles.Delay;
using NzbDrone.Core.Movies;
using NzbDrone.Core.Profiles;
using NzbDrone.Core.Qualities;
using NzbDrone.Core.Parser.Model;
using NzbDrone.Core.DecisionEngine;
using NUnit.Framework;
using FluentAssertions;
using FizzWare.NBuilder;
using FluentAssertions;
using Moq;
using NUnit.Framework;
using NzbDrone.Common.Extensions;
using NzbDrone.Core.DecisionEngine;
using NzbDrone.Core.Indexers;
using NzbDrone.Core.Movies;
using NzbDrone.Core.Parser.Model;
using NzbDrone.Core.Profiles;
using NzbDrone.Core.Profiles.Delay;
using NzbDrone.Core.Qualities;
using NzbDrone.Core.Test.CustomFormat;
using NzbDrone.Core.Test.Framework;
namespace NzbDrone.Core.Test.DecisionEngineTests
{
[TestFixture]
//TODO: Update for custom qualities!
public class PrioritizeDownloadDecisionFixture : CoreTest<DownloadDecisionPriorizationService>
{
@@ -30,8 +31,8 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
{
GivenPreferredDownloadProtocol(DownloadProtocol.Usenet);
_customFormat1 = new CustomFormats.CustomFormat("My Format 1", "L_ENGLISH"){Id=1};
_customFormat2 = new CustomFormats.CustomFormat("My Format 2", "L_FRENCH"){Id=2};
_customFormat1 = new CustomFormats.CustomFormat("My Format 1", "L_ENGLISH") { Id = 1 };
_customFormat2 = new CustomFormats.CustomFormat("My Format 2", "L_FRENCH") { Id = 2 };
CustomFormatsFixture.GivenCustomFormats(CustomFormats.CustomFormat.None, _customFormat1, _customFormat2);
}
@@ -44,8 +45,12 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
remoteMovie.ParsedMovieInfo.Year = 1998;
remoteMovie.ParsedMovieInfo.Quality = quality;
remoteMovie.Movie = Builder<Movie>.CreateNew().With(m => m.Profile = new Profile { Items = Qualities.QualityFixture.GetDefaultQualities(),
PreferredTags = new List<string> { "DTS-HD", "SPARKS"}, FormatItems = CustomFormatsFixture.GetSampleFormatItems() })
remoteMovie.Movie = Builder<Movie>.CreateNew().With(m => m.Profile = new Profile
{
Items = Qualities.QualityFixture.GetDefaultQualities(),
PreferredTags = new List<string> { "DTS-HD", "SPARKS" },
FormatItems = CustomFormatsFixture.GetSampleFormatItems()
})
.With(m => m.Title = "A Movie").Build();
remoteMovie.Release = new ReleaseInfo();
@@ -119,7 +124,6 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
var remoteEpisode1 = GivenRemoteMovie(new QualityModel(Quality.HDTV720p), age: 10);
var remoteEpisode2 = GivenRemoteMovie(new QualityModel(Quality.HDTV720p), age: 5);
var decisions = new List<DownloadDecision>();
decisions.Add(new DownloadDecision(remoteEpisode1));
decisions.Add(new DownloadDecision(remoteEpisode2));
@@ -185,7 +189,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
decisions.Add(new DownloadDecision(remoteEpisode2));
var qualifiedReports = Subject.PrioritizeDecisionsForMovies(decisions);
((TorrentInfo) qualifiedReports.First().RemoteMovie.Release).Seeders.Should().Be(torrentInfo2.Seeders);
((TorrentInfo)qualifiedReports.First().RemoteMovie.Release).Seeders.Should().Be(torrentInfo2.Seeders);
}
[Test]
@@ -201,7 +205,6 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
torrentInfo1.Seeders = 10;
torrentInfo1.Peers = 10;
var torrentInfo2 = torrentInfo1.JsonClone();
torrentInfo2.Peers = 100;
@@ -231,7 +234,6 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
torrentInfo1.Seeders = 0;
torrentInfo1.Peers = 10;
var torrentInfo2 = torrentInfo1.JsonClone();
torrentInfo2.Seeders = 0;
torrentInfo2.Peers = 100;
@@ -277,7 +279,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
decisions.Add(new DownloadDecision(remoteEpisode2));
var qualifiedReports = Subject.PrioritizeDecisionsForMovies(decisions);
((TorrentInfo) qualifiedReports.First().RemoteMovie.Release).Should().Be(torrentInfo1);
((TorrentInfo)qualifiedReports.First().RemoteMovie.Release).Should().Be(torrentInfo1);
}
[Test]
@@ -4,10 +4,10 @@ using Moq;
using NUnit.Framework;
using NzbDrone.Core.DecisionEngine.Specifications;
using NzbDrone.Core.Indexers;
using NzbDrone.Core.Movies;
using NzbDrone.Core.Parser.Model;
using NzbDrone.Core.Profiles.Delay;
using NzbDrone.Core.Test.Framework;
using NzbDrone.Core.Movies;
namespace NzbDrone.Core.Test.DecisionEngineTests
{
@@ -3,10 +3,10 @@ using FluentAssertions;
using Marr.Data;
using NUnit.Framework;
using NzbDrone.Core.DecisionEngine.Specifications;
using NzbDrone.Core.Movies;
using NzbDrone.Core.Parser.Model;
using NzbDrone.Core.Profiles;
using NzbDrone.Core.Qualities;
using NzbDrone.Core.Movies;
using NzbDrone.Core.Test.Framework;
namespace NzbDrone.Core.Test.DecisionEngineTests
@@ -15,7 +15,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
public class QualityAllowedByProfileSpecificationFixture : CoreTest<QualityAllowedByProfileSpecification>
{
private RemoteMovie remoteMovie;
private RemoteMovie _remoteMovie;
public static object[] AllowedTestCases =
{
@@ -38,29 +38,31 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
.With(c => c.Profile = (LazyLoaded<Profile>)new Profile { Cutoff = Quality.Bluray1080p.Id })
.Build();
remoteMovie = new RemoteMovie
_remoteMovie = new RemoteMovie
{
Movie = fakeSeries,
ParsedMovieInfo = new ParsedMovieInfo { Quality = new QualityModel(Quality.DVD, new Revision(version: 2)) },
};
}
[Test, TestCaseSource("AllowedTestCases")]
[Test]
[TestCaseSource("AllowedTestCases")]
public void should_allow_if_quality_is_defined_in_profile(Quality qualityType)
{
remoteMovie.ParsedMovieInfo.Quality.Quality = qualityType;
remoteMovie.Movie.Profile.Value.Items = Qualities.QualityFixture.GetDefaultQualities(Quality.DVD, Quality.HDTV720p, Quality.Bluray1080p);
_remoteMovie.ParsedMovieInfo.Quality.Quality = qualityType;
_remoteMovie.Movie.Profile.Value.Items = Qualities.QualityFixture.GetDefaultQualities(Quality.DVD, Quality.HDTV720p, Quality.Bluray1080p);
Subject.IsSatisfiedBy(remoteMovie, null).Accepted.Should().BeTrue();
Subject.IsSatisfiedBy(_remoteMovie, null).Accepted.Should().BeTrue();
}
[Test, TestCaseSource("DeniedTestCases")]
[Test]
[TestCaseSource("DeniedTestCases")]
public void should_not_allow_if_quality_is_not_defined_in_profile(Quality qualityType)
{
remoteMovie.ParsedMovieInfo.Quality.Quality = qualityType;
remoteMovie.Movie.Profile.Value.Items = Qualities.QualityFixture.GetDefaultQualities(Quality.DVD, Quality.HDTV720p, Quality.Bluray1080p);
_remoteMovie.ParsedMovieInfo.Quality.Quality = qualityType;
_remoteMovie.Movie.Profile.Value.Items = Qualities.QualityFixture.GetDefaultQualities(Quality.DVD, Quality.HDTV720p, Quality.Bluray1080p);
Subject.IsSatisfiedBy(remoteMovie, null).Accepted.Should().BeFalse();
Subject.IsSatisfiedBy(_remoteMovie, null).Accepted.Should().BeFalse();
}
}
}
@@ -1,9 +1,9 @@
using FluentAssertions;
using NUnit.Framework;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.DecisionEngine.Specifications;
using NzbDrone.Core.Profiles;
using NzbDrone.Core.Qualities;
using NzbDrone.Core.DecisionEngine.Specifications;
using NzbDrone.Core.Test.Framework;
namespace NzbDrone.Core.Test.DecisionEngineTests
@@ -26,7 +26,6 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
[SetUp]
public void Setup()
{
}
private void GivenAutoDownloadPropers(bool autoDownloadPropers)
@@ -36,7 +35,8 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
.Returns(autoDownloadPropers);
}
[Test, TestCaseSource("IsUpgradeTestCases")]
[Test]
[TestCaseSource("IsUpgradeTestCases")]
public void IsUpgradeTest(Quality current, int currentVersion, Quality newQuality, int newVersion, Quality cutoff, bool expected)
{
GivenAutoDownloadPropers(true);
@@ -58,7 +58,6 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
.Should().BeFalse();
}
[Test]
public void should_return_false_if_release_and_existing_file_are_the_same()
{
@@ -4,11 +4,11 @@ using FizzWare.NBuilder;
using FluentAssertions;
using NUnit.Framework;
using NzbDrone.Core.DecisionEngine.Specifications;
using NzbDrone.Core.Movies;
using NzbDrone.Core.Parser.Model;
using NzbDrone.Core.Profiles;
using NzbDrone.Core.Qualities;
using NzbDrone.Core.Queue;
using NzbDrone.Core.Movies;
using NzbDrone.Core.Test.Framework;
namespace NzbDrone.Core.Test.DecisionEngineTests
@@ -27,7 +27,8 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
Mocker.Resolve<UpgradableSpecification>();
_movie = Builder<Movie>.CreateNew()
.With(e => e.Profile = new Profile {
.With(e => e.Profile = new Profile
{
Items = Qualities.QualityFixture.GetDefaultQualities(),
UpgradeAllowed = true
})
@@ -88,9 +89,9 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
var remoteMovie = Builder<RemoteMovie>.CreateNew()
.With(r => r.Movie = _movie)
.With(r => r.ParsedMovieInfo = new ParsedMovieInfo
{
Quality = new QualityModel(Quality.SDTV)
})
{
Quality = new QualityModel(Quality.SDTV)
})
.Build();
GivenQueue(new List<RemoteMovie> { remoteMovie });
@@ -103,9 +104,9 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
var remoteMovie = Builder<RemoteMovie>.CreateNew()
.With(r => r.Movie = _movie)
.With(r => r.ParsedMovieInfo = new ParsedMovieInfo
{
Quality = new QualityModel(Quality.DVD)
})
{
Quality = new QualityModel(Quality.DVD)
})
.Build();
GivenQueue(new List<RemoteMovie> { remoteMovie });
@@ -120,9 +121,9 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
var remoteMovie = Builder<RemoteMovie>.CreateNew()
.With(r => r.Movie = _movie)
.With(r => r.ParsedMovieInfo = new ParsedMovieInfo
{
Quality = new QualityModel(Quality.HDTV720p)
})
{
Quality = new QualityModel(Quality.HDTV720p)
})
.Build();
GivenQueue(new List<RemoteMovie> { remoteMovie });
@@ -147,7 +148,6 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
Subject.IsSatisfiedBy(_remoteMovie, null).Accepted.Should().BeFalse();
}
[Test]
public void should_return_false_when_quality_is_better_and_upgrade_allowed_is_false_for_quality_profile()
{
@@ -1,10 +1,9 @@
using FluentAssertions;
using NUnit.Framework;
using NzbDrone.Core.DecisionEngine.Specifications;
using NzbDrone.Core.Parser.Model;
using NzbDrone.Core.Test.Framework;
using NzbDrone.Core.Indexers;
using NzbDrone.Core.Parser.Model;
using NzbDrone.Core.Test.Framework;
namespace NzbDrone.Core.Test.DecisionEngineTests
{
@@ -20,10 +19,10 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
_remoteMovie = new RemoteMovie
{
Release = new ReleaseInfo
{
Title = "Movie.title.1998",
DownloadProtocol = DownloadProtocol.Torrent
}
{
Title = "Movie.title.1998",
DownloadProtocol = DownloadProtocol.Torrent
}
};
}
@@ -3,10 +3,10 @@ using FluentAssertions;
using Moq;
using NUnit.Framework;
using NzbDrone.Core.DecisionEngine.Specifications;
using NzbDrone.Core.Movies;
using NzbDrone.Core.Parser.Model;
using NzbDrone.Core.Restrictions;
using NzbDrone.Core.Test.Framework;
using NzbDrone.Core.Movies;
namespace NzbDrone.Core.Test.DecisionEngineTests
{
@@ -20,15 +20,15 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
{
_remoteMovie = new RemoteMovie
{
Movie = new Movie
{
Tags = new HashSet<int>()
},
Release = new ReleaseInfo
{
Title = "Dexter.S08E01.EDITED.WEBRip.x264-KYR"
}
};
Movie = new Movie
{
Tags = new HashSet<int>()
},
Release = new ReleaseInfo
{
Title = "Dexter.S08E01.EDITED.WEBRip.x264-KYR"
}
};
Mocker.SetConstant<ITermMatcher>(Mocker.Resolve<TermMatcher>());
}
@@ -1,12 +1,12 @@
using FizzWare.NBuilder;
using FluentAssertions;
using NUnit.Framework;
using NzbDrone.Core.Qualities;
using NzbDrone.Core.DecisionEngine.Specifications;
using NzbDrone.Core.MediaFiles;
using NzbDrone.Core.Test.Framework;
using NzbDrone.Core.Parser.Model;
using NzbDrone.Core.Movies;
using NzbDrone.Core.Parser.Model;
using NzbDrone.Core.Qualities;
using NzbDrone.Core.Test.Framework;
namespace NzbDrone.Core.Test.DecisionEngineTests
{
@@ -11,12 +11,12 @@ using NzbDrone.Core.Download.Pending;
using NzbDrone.Core.Indexers;
using NzbDrone.Core.IndexerSearch.Definitions;
using NzbDrone.Core.MediaFiles;
using NzbDrone.Core.Movies;
using NzbDrone.Core.Parser.Model;
using NzbDrone.Core.Profiles;
using NzbDrone.Core.Profiles.Delay;
using NzbDrone.Core.Qualities;
using NzbDrone.Core.Test.Framework;
using NzbDrone.Core.Movies;
namespace NzbDrone.Core.Test.DecisionEngineTests.RssSync
{
@@ -58,7 +58,6 @@ namespace NzbDrone.Core.Test.DecisionEngineTests.RssSync
//_remoteEpisode.Episodes = Builder<Episode>.CreateListOfSize(1).Build().ToList();
//_remoteEpisode.Episodes.First().EpisodeFileId = 0;
Mocker.GetMock<IDelayProfileService>()
.Setup(s => s.BestForTags(It.IsAny<HashSet<int>>()))
.Returns(_delayProfile);
@@ -76,7 +75,6 @@ namespace NzbDrone.Core.Test.DecisionEngineTests.RssSync
// {
// Quality = quality
// });
_remoteEpisode.Movie.MovieFile = new LazyLoaded<MovieFile>(new MovieFile { Quality = quality });
}
@@ -3,15 +3,14 @@ using FizzWare.NBuilder;
using FluentAssertions;
using NUnit.Framework;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.DecisionEngine.Specifications;
using NzbDrone.Core.DecisionEngine.Specifications.RssSync;
using NzbDrone.Core.IndexerSearch.Definitions;
using NzbDrone.Core.MediaFiles;
using NzbDrone.Core.Movies;
using NzbDrone.Core.Parser.Model;
using NzbDrone.Core.Profiles;
using NzbDrone.Core.Qualities;
using NzbDrone.Core.Movies;
using NzbDrone.Core.DecisionEngine.Specifications;
using NzbDrone.Core.Test.Framework;
namespace NzbDrone.Core.Test.DecisionEngineTests.RssSync
@@ -3,8 +3,8 @@ using FluentAssertions;
using NUnit.Framework;
using NzbDrone.Core.DecisionEngine.Specifications.Search;
using NzbDrone.Core.IndexerSearch.Definitions;
using NzbDrone.Core.Parser.Model;
using NzbDrone.Core.Movies;
using NzbDrone.Core.Parser.Model;
using NzbDrone.Test.Common;
namespace NzbDrone.Core.Test.DecisionEngineTests.Search
@@ -6,8 +6,8 @@ using NzbDrone.Core.Datastore;
using NzbDrone.Core.DecisionEngine.Specifications;
using NzbDrone.Core.Indexers;
using NzbDrone.Core.Indexers.TorrentRss;
using NzbDrone.Core.Parser.Model;
using NzbDrone.Core.Movies;
using NzbDrone.Core.Parser.Model;
using NzbDrone.Test.Common;
namespace NzbDrone.Core.Test.DecisionEngineTests.Search
@@ -32,6 +32,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests.Search
IndexerId = 1,
Title = "Series.Title.S01.720p.BluRay.X264-RlsGrp",
Seeders = 0,
//IndexerSettings = new TorrentRssIndexerSettings {MinimumSeeders = 5}
}
};
@@ -64,7 +65,6 @@ namespace NzbDrone.Core.Test.DecisionEngineTests.Search
}
// These tests are not needed anymore, since indexer settings are saved on the release itself!
[Test]
public void should_return_true_if_indexer_not_specified()
{
@@ -4,10 +4,10 @@ using FluentAssertions;
using NUnit.Framework;
using NzbDrone.Core.DecisionEngine.Specifications;
using NzbDrone.Core.MediaFiles;
using NzbDrone.Core.Movies;
using NzbDrone.Core.Parser.Model;
using NzbDrone.Core.Profiles;
using NzbDrone.Core.Qualities;
using NzbDrone.Core.Movies;
using NzbDrone.Core.Test.Framework;
namespace NzbDrone.Core.Test.DecisionEngineTests