1
0
mirror of https://github.com/Radarr/Radarr.git synced 2024-11-04 10:02:40 +01:00

Quality moved to ObjectDb.

This commit is contained in:
Mark McDowall 2013-02-26 19:19:22 -08:00
parent 065b86c159
commit c6836e0cb1
79 changed files with 800 additions and 966 deletions

View File

@ -7,7 +7,7 @@
using NzbDrone.Api.Series;
using NzbDrone.Api.Upcoming;
using NzbDrone.Core.Datastore;
using NzbDrone.Core.Repository.Quality;
using NzbDrone.Core.Qualities;
using NzbDrone.Core.Tv;
namespace NzbDrone.Api
@ -19,24 +19,22 @@ public static void InitializeAutomapper()
{
//QualityProfiles
Mapper.CreateMap<QualityProfile, QualityProfileModel>()
.ForMember(dest => dest.Id, opt => opt.MapFrom(src => src.QualityProfileId))
.ForMember(dest => dest.Qualities,
opt => opt.ResolveUsing<AllowedToQualitiesResolver>().FromMember(src => src.Allowed));
Mapper.CreateMap<QualityProfileModel, QualityProfile>()
.ForMember(dest => dest.QualityProfileId, opt => opt.MapFrom(src => src.Id))
.ForMember(dest => dest.Allowed,
opt => opt.ResolveUsing<QualitiesToAllowedResolver>().FromMember(src => src.Qualities));
Mapper.CreateMap<QualityTypes, QualityProfileType>()
Mapper.CreateMap<Quality, QualityProfileType>()
.ForMember(dest => dest.Allowed, opt => opt.Ignore());
//QualityTypes
Mapper.CreateMap<Core.Repository.Quality.QualityType, QualityTypeModel>()
.ForMember(dest => dest.Id, opt => opt.MapFrom(src => src.QualityTypeId));
//QualitySize
Mapper.CreateMap<QualitySize, QualityTypeModel>()
.ForMember(dest => dest.Id, opt => opt.MapFrom(src => src.QualityId));
Mapper.CreateMap<QualityTypeModel, Core.Repository.Quality.QualityType>()
.ForMember(dest => dest.QualityTypeId, opt => opt.MapFrom(src => src.Id));
Mapper.CreateMap<QualityTypeModel, QualitySize>()
.ForMember(dest => dest.QualityId, opt => opt.MapFrom(src => src.Id));
//Series
Mapper.CreateMap<Core.Tv.Series, SeriesResource>()

View File

@ -4,16 +4,16 @@
using Nancy;
using NzbDrone.Api.Extensions;
using NzbDrone.Core.Providers;
using NzbDrone.Core.Repository.Quality;
using NzbDrone.Api.QualityType;
using NzbDrone.Core.Qualities;
namespace NzbDrone.Api.QualityProfiles
{
public class QualityProfilesModule : NzbDroneApiModule
{
private readonly QualityProvider _qualityProvider;
private readonly QualityProfileService _qualityProvider;
public QualityProfilesModule(QualityProvider qualityProvider)
public QualityProfilesModule(QualityProfileService qualityProvider)
: base("/QualityProfiles")
{
_qualityProvider = qualityProvider;
@ -39,7 +39,7 @@ private Response OnPost()
{
var request = Request.Body.FromJson<QualityProfileModel>();
var profile = Mapper.Map<QualityProfileModel, QualityProfile>(request);
request.Id = _qualityProvider.Add(profile);
request.Id = _qualityProvider.Add(profile).Id;
return request.AsResponse();
}

View File

@ -5,14 +5,15 @@
using NzbDrone.Api.Extensions;
using NzbDrone.Api.QualityProfiles;
using NzbDrone.Core.Providers;
using NzbDrone.Core.Qualities;
namespace NzbDrone.Api.QualityType
{
public class QualityTypeModule : NzbDroneApiModule
{
private readonly QualityTypeProvider _qualityTypeProvider;
private readonly QualitySizeService _qualityTypeProvider;
public QualityTypeModule(QualityTypeProvider qualityTypeProvider)
public QualityTypeModule(QualitySizeService qualityTypeProvider)
: base("/QualityTypes")
{
_qualityTypeProvider = qualityTypeProvider;
@ -26,7 +27,7 @@ private Response PutQualityType()
{
var model = Request.Body.FromJson<QualityTypeModel>();
var type = Mapper.Map<QualityTypeModel, Core.Repository.Quality.QualityType>(model);
var type = Mapper.Map<QualityTypeModel, QualitySize>(model);
_qualityTypeProvider.Update(type);
return model.AsResponse();
@ -36,13 +37,13 @@ private Response PutQualityType()
private Response GetQualityType(int id)
{
var type = _qualityTypeProvider.Get(id);
return Mapper.Map<Core.Repository.Quality.QualityType, QualityTypeModel>(type).AsResponse();
return Mapper.Map<QualitySize, QualityTypeModel>(type).AsResponse();
}
private Response GetQualityType()
{
var types = _qualityTypeProvider.All().Where(qualityType => qualityType.QualityTypeId != 0 && qualityType.QualityTypeId != 10).ToList();
var responseModel = Mapper.Map<List<Core.Repository.Quality.QualityType>, List<QualityTypeModel>>(types);
var types = _qualityTypeProvider.All().Where(qualityType => qualityType.QualityId != 0 && qualityType.QualityId != 10).ToList();
var responseModel = Mapper.Map<List<QualitySize>, List<QualityTypeModel>>(types);
return responseModel.AsResponse();
}

View File

@ -3,15 +3,15 @@
using System.Linq;
using AutoMapper;
using NzbDrone.Api.QualityProfiles;
using NzbDrone.Core.Repository.Quality;
using NzbDrone.Core.Qualities;
namespace NzbDrone.Api.Resolvers
{
public class AllowedToQualitiesResolver : ValueResolver<List<QualityTypes>, List<QualityProfileType>>
public class AllowedToQualitiesResolver : ValueResolver<List<Quality>, List<QualityProfileType>>
{
protected override List<QualityProfileType> ResolveCore(List<QualityTypes> source)
protected override List<QualityProfileType> ResolveCore(List<Quality> source)
{
var qualities = Mapper.Map<List<QualityTypes>, List<QualityProfileType>>(QualityTypes.All().Where(q => q.Id > 0).ToList());
var qualities = Mapper.Map<List<Quality>, List<QualityProfileType>>(Quality.All().Where(q => q.Id > 0).ToList());
qualities.ForEach(quality =>
{

View File

@ -3,7 +3,6 @@
using System.Linq;
using AutoMapper;
using NzbDrone.Api.QualityProfiles;
using NzbDrone.Core.Repository.Quality;
using NzbDrone.Core.Tv;
namespace NzbDrone.Api.Resolvers

View File

@ -3,7 +3,6 @@
using System.Linq;
using AutoMapper;
using NzbDrone.Api.QualityProfiles;
using NzbDrone.Core.Repository.Quality;
namespace NzbDrone.Api.Resolvers
{

View File

@ -4,21 +4,21 @@
using System.Text;
using AutoMapper;
using NzbDrone.Api.QualityProfiles;
using NzbDrone.Core.Repository.Quality;
using NzbDrone.Core.Qualities;
namespace NzbDrone.Api.Resolvers
{
public class QualitiesToAllowedResolver : ValueResolver<List<QualityProfileType>, List<QualityTypes>>
public class QualitiesToAllowedResolver : ValueResolver<List<QualityProfileType>, List<Quality>>
{
protected override List<QualityTypes> ResolveCore(List<QualityProfileType> source)
protected override List<Quality> ResolveCore(List<QualityProfileType> source)
{
var ids = source.Where(s => s.Allowed).Select(s => s.Id).ToList();
var qualityTypes = new List<QualityTypes>();
var qualityTypes = new List<Quality>();
ids.ForEach(id =>
{
qualityTypes.Add(QualityTypes.FindById(id));
qualityTypes.Add(Quality.FindById(id));
});
return qualityTypes;

View File

@ -3,13 +3,13 @@
using System.Linq;
using System.Text;
using AutoMapper;
using NzbDrone.Core.Repository.Quality;
using NzbDrone.Core.Qualities;
namespace NzbDrone.Api.Resolvers
{
public class QualityTypesToIntResolver : ValueResolver<QualityTypes, Int32>
public class QualityTypesToIntResolver : ValueResolver<Quality, Int32>
{
protected override int ResolveCore(QualityTypes source)
protected override int ResolveCore(Quality source)
{
return source.Id;
}

View File

@ -12,6 +12,7 @@
using NzbDrone.Core.Jobs;
using NzbDrone.Core.Providers;
using NzbDrone.Core.Providers.Metadata;
using NzbDrone.Core.Qualities;
using NzbDrone.Core.Test.Framework;
namespace NzbDrone.Core.Test
@ -124,7 +125,7 @@ public void metadata_clients_are_initialized()
[Test]
public void quality_profile_initialized()
{
kernel.Resolve<QualityProvider>().All().Should().HaveCount(2);
kernel.Resolve<QualityProfileService>().All().Should().HaveCount(2);
}
[Test]

View File

@ -7,12 +7,12 @@
using FluentAssertions;
using Moq;
using NUnit.Framework;
using NzbDrone.Core.Qualities;
using NzbDrone.Core.Tv;
using NzbDrone.Core.Model;
using NzbDrone.Core.Providers;
using NzbDrone.Core.DecisionEngine;
using NzbDrone.Core.Repository;
using NzbDrone.Core.Repository.Quality;
using NzbDrone.Core.Test.Framework;
namespace NzbDrone.Core.Test.DecisionEngineTests
@ -25,7 +25,7 @@ public class AcceptableSizeSpecificationFixture : CoreTest
private EpisodeParseResult parseResultSingle;
private Series series30minutes;
private Series series60minutes;
private QualityType qualityType;
private QualitySize qualityType;
[SetUp]
public void Setup()
@ -34,7 +34,7 @@ public void Setup()
{
SeriesTitle = "Title",
Language = LanguageType.English,
Quality = new QualityModel(QualityTypes.SDTV, true),
Quality = new QualityModel(Quality.SDTV, true),
EpisodeNumbers = new List<int> { 3, 4 },
SeasonNumber = 12,
AirDate = DateTime.Now.AddDays(-12).Date
@ -44,7 +44,7 @@ public void Setup()
{
SeriesTitle = "Title",
Language = LanguageType.English,
Quality = new QualityModel(QualityTypes.SDTV, true),
Quality = new QualityModel(Quality.SDTV, true),
EpisodeNumbers = new List<int> { 3 },
SeasonNumber = 12,
AirDate = DateTime.Now.AddDays(-12).Date
@ -62,10 +62,10 @@ public void Setup()
.With(c => c.Runtime = 60)
.Build();
qualityType = Builder<QualityType>.CreateNew()
qualityType = Builder<QualitySize>.CreateNew()
.With(q => q.MinSize = 0)
.With(q => q.MaxSize = 10)
.With(q => q.QualityTypeId = 1)
.With(q => q.QualityId = 1)
.Build();
}
@ -78,7 +78,7 @@ public void IsAcceptableSize_true_single_episode_not_first_or_last_30_minute()
parseResultSingle.Series = series30minutes;
parseResultSingle.Size = 184572800;
Mocker.GetMock<QualityTypeProvider>().Setup(s => s.Get(1)).Returns(qualityType);
Mocker.GetMock<QualitySizeService>().Setup(s => s.Get(1)).Returns(qualityType);
Mocker.GetMock<IEpisodeService>().Setup(
s => s.IsFirstOrLastEpisodeOfSeason(It.IsAny<int>(), It.IsAny<int>(), It.IsAny<int>()))
@ -99,7 +99,7 @@ public void IsAcceptableSize_true_single_episode_not_first_or_last_60_minute()
parseResultSingle.Series = series60minutes;
parseResultSingle.Size = 368572800;
Mocker.GetMock<QualityTypeProvider>().Setup(s => s.Get(1)).Returns(qualityType);
Mocker.GetMock<QualitySizeService>().Setup(s => s.Get(1)).Returns(qualityType);
Mocker.GetMock<IEpisodeService>().Setup(
s => s.IsFirstOrLastEpisodeOfSeason(It.IsAny<int>(), It.IsAny<int>(), It.IsAny<int>()))
@ -120,7 +120,7 @@ public void IsAcceptableSize_false_single_episode_not_first_or_last_30_minute()
parseResultSingle.Series = series30minutes;
parseResultSingle.Size = 1.Gigabytes();
Mocker.GetMock<QualityTypeProvider>().Setup(s => s.Get(1)).Returns(qualityType);
Mocker.GetMock<QualitySizeService>().Setup(s => s.Get(1)).Returns(qualityType);
Mocker.GetMock<IEpisodeService>().Setup(
s => s.IsFirstOrLastEpisodeOfSeason(It.IsAny<int>(), It.IsAny<int>(), It.IsAny<int>()))
@ -141,7 +141,7 @@ public void IsAcceptableSize_false_single_episode_not_first_or_last_60_minute()
parseResultSingle.Series = series60minutes;
parseResultSingle.Size = 1.Gigabytes();
Mocker.GetMock<QualityTypeProvider>().Setup(s => s.Get(1)).Returns(qualityType);
Mocker.GetMock<QualitySizeService>().Setup(s => s.Get(1)).Returns(qualityType);
Mocker.GetMock<IEpisodeService>().Setup(
s => s.IsFirstOrLastEpisodeOfSeason(It.IsAny<int>(), It.IsAny<int>(), It.IsAny<int>()))
@ -162,7 +162,7 @@ public void IsAcceptableSize_true_multi_episode_not_first_or_last_30_minute()
parseResultMulti.Series = series30minutes;
parseResultMulti.Size = 184572800;
Mocker.GetMock<QualityTypeProvider>().Setup(s => s.Get(1)).Returns(qualityType);
Mocker.GetMock<QualitySizeService>().Setup(s => s.Get(1)).Returns(qualityType);
Mocker.GetMock<IEpisodeService>().Setup(
s => s.IsFirstOrLastEpisodeOfSeason(It.IsAny<int>(), It.IsAny<int>(), It.IsAny<int>()))
@ -183,7 +183,7 @@ public void IsAcceptableSize_true_multi_episode_not_first_or_last_60_minute()
parseResultMulti.Series = series60minutes;
parseResultMulti.Size = 368572800;
Mocker.GetMock<QualityTypeProvider>().Setup(s => s.Get(1)).Returns(qualityType);
Mocker.GetMock<QualitySizeService>().Setup(s => s.Get(1)).Returns(qualityType);
Mocker.GetMock<IEpisodeService>().Setup(
s => s.IsFirstOrLastEpisodeOfSeason(It.IsAny<int>(), It.IsAny<int>(), It.IsAny<int>()))
@ -204,7 +204,7 @@ public void IsAcceptableSize_false_multi_episode_not_first_or_last_30_minute()
parseResultMulti.Series = series30minutes;
parseResultMulti.Size = 1.Gigabytes();
Mocker.GetMock<QualityTypeProvider>().Setup(s => s.Get(1)).Returns(qualityType);
Mocker.GetMock<QualitySizeService>().Setup(s => s.Get(1)).Returns(qualityType);
Mocker.GetMock<IEpisodeService>().Setup(
s => s.IsFirstOrLastEpisodeOfSeason(It.IsAny<int>(), It.IsAny<int>(), It.IsAny<int>()))
@ -225,7 +225,7 @@ public void IsAcceptableSize_false_multi_episode_not_first_or_last_60_minute()
parseResultMulti.Series = series60minutes;
parseResultMulti.Size = 10.Gigabytes();
Mocker.GetMock<QualityTypeProvider>().Setup(s => s.Get(1)).Returns(qualityType);
Mocker.GetMock<QualitySizeService>().Setup(s => s.Get(1)).Returns(qualityType);
Mocker.GetMock<IEpisodeService>().Setup(
s => s.IsFirstOrLastEpisodeOfSeason(It.IsAny<int>(), It.IsAny<int>(), It.IsAny<int>()))
@ -246,7 +246,7 @@ public void IsAcceptableSize_true_single_episode_first_30_minute()
parseResultSingle.Series = series30minutes;
parseResultSingle.Size = 184572800;
Mocker.GetMock<QualityTypeProvider>().Setup(s => s.Get(1)).Returns(qualityType);
Mocker.GetMock<QualitySizeService>().Setup(s => s.Get(1)).Returns(qualityType);
Mocker.GetMock<IEpisodeService>().Setup(
s => s.IsFirstOrLastEpisodeOfSeason(It.IsAny<int>(), It.IsAny<int>(), It.IsAny<int>()))
@ -267,7 +267,7 @@ public void IsAcceptableSize_true_single_episode_first_60_minute()
parseResultSingle.Series = series60minutes;
parseResultSingle.Size = 368572800;
Mocker.GetMock<QualityTypeProvider>().Setup(s => s.Get(1)).Returns(qualityType);
Mocker.GetMock<QualitySizeService>().Setup(s => s.Get(1)).Returns(qualityType);
Mocker.GetMock<IEpisodeService>().Setup(
s => s.IsFirstOrLastEpisodeOfSeason(It.IsAny<int>(), It.IsAny<int>(), It.IsAny<int>()))
@ -288,7 +288,7 @@ public void IsAcceptableSize_false_single_episode_first_30_minute()
parseResultSingle.Series = series30minutes;
parseResultSingle.Size = 1.Gigabytes();
Mocker.GetMock<QualityTypeProvider>().Setup(s => s.Get(1)).Returns(qualityType);
Mocker.GetMock<QualitySizeService>().Setup(s => s.Get(1)).Returns(qualityType);
Mocker.GetMock<IEpisodeService>().Setup(
s => s.IsFirstOrLastEpisodeOfSeason(It.IsAny<int>(), It.IsAny<int>(), It.IsAny<int>()))
@ -309,7 +309,7 @@ public void IsAcceptableSize_false_single_episode_first_60_minute()
parseResultSingle.Series = series60minutes;
parseResultSingle.Size = 10.Gigabytes();
Mocker.GetMock<QualityTypeProvider>().Setup(s => s.Get(1)).Returns(qualityType);
Mocker.GetMock<QualitySizeService>().Setup(s => s.Get(1)).Returns(qualityType);
Mocker.GetMock<IEpisodeService>().Setup(
s => s.IsFirstOrLastEpisodeOfSeason(It.IsAny<int>(), It.IsAny<int>(), It.IsAny<int>()))
@ -331,7 +331,7 @@ public void IsAcceptableSize_true_unlimited_30_minute()
parseResultSingle.Size = 18457280000;
qualityType.MaxSize = 0;
Mocker.GetMock<QualityTypeProvider>().Setup(s => s.Get(1)).Returns(qualityType);
Mocker.GetMock<QualitySizeService>().Setup(s => s.Get(1)).Returns(qualityType);
Mocker.GetMock<IEpisodeService>().Setup(
s => s.IsFirstOrLastEpisodeOfSeason(It.IsAny<int>(), It.IsAny<int>(), It.IsAny<int>()))
@ -353,7 +353,7 @@ public void IsAcceptableSize_true_unlimited_60_minute()
parseResultSingle.Size = 36857280000;
qualityType.MaxSize = 0;
Mocker.GetMock<QualityTypeProvider>().Setup(s => s.Get(1)).Returns(qualityType);
Mocker.GetMock<QualitySizeService>().Setup(s => s.Get(1)).Returns(qualityType);
Mocker.GetMock<IEpisodeService>().Setup(
s => s.IsFirstOrLastEpisodeOfSeason(It.IsAny<int>(), It.IsAny<int>(), It.IsAny<int>()))
@ -376,7 +376,7 @@ public void IsAcceptableSize_should_treat_daily_series_as_single_episode()
qualityType.MaxSize = (int)600.Megabytes();
Mocker.GetMock<QualityTypeProvider>().Setup(s => s.Get(1)).Returns(qualityType);
Mocker.GetMock<QualitySizeService>().Setup(s => s.Get(1)).Returns(qualityType);
Mocker.GetMock<IEpisodeService>().Setup(
s => s.IsFirstOrLastEpisodeOfSeason(It.IsAny<int>(), It.IsAny<int>(), It.IsAny<int>()))
@ -394,7 +394,7 @@ public void should_return_true_if_RAWHD()
{
var parseResult = new EpisodeParseResult
{
Quality = new QualityModel(QualityTypes.RAWHD, false)
Quality = new QualityModel(Quality.RAWHD, false)
};
Mocker.Resolve<AcceptableSizeSpecification>().IsSatisfiedBy(parseResult).Should().BeTrue();

View File

@ -11,7 +11,6 @@
using NzbDrone.Core.Providers;
using NzbDrone.Core.DecisionEngine;
using NzbDrone.Core.Repository;
using NzbDrone.Core.Repository.Quality;
using NzbDrone.Core.Test.Framework;
namespace NzbDrone.Core.Test.DecisionEngineTests

View File

@ -8,13 +8,13 @@
using Moq;
using NUnit.Framework;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Qualities;
using NzbDrone.Core.Tv;
using NzbDrone.Core.Model;
using NzbDrone.Core.Providers;
using NzbDrone.Core.Providers.Core;
using NzbDrone.Core.DecisionEngine;
using NzbDrone.Core.Repository;
using NzbDrone.Core.Repository.Quality;
using NzbDrone.Core.Test.Framework;
namespace NzbDrone.Core.Test.DecisionEngineTests
@ -32,7 +32,7 @@ public void Setup()
{
SeriesTitle = "Title",
Language = LanguageType.English,
Quality = new QualityModel(QualityTypes.SDTV, true),
Quality = new QualityModel(Quality.SDTV, true),
EpisodeNumbers = new List<int> { 3 },
SeasonNumber = 12,
AirDate = DateTime.Now.AddDays(-12).Date,

View File

@ -5,11 +5,11 @@
using FizzWare.NBuilder;
using FluentAssertions;
using NUnit.Framework;
using NzbDrone.Core.Qualities;
using NzbDrone.Core.Tv;
using NzbDrone.Core.Model;
using NzbDrone.Core.DecisionEngine;
using NzbDrone.Core.Repository;
using NzbDrone.Core.Repository.Quality;
using NzbDrone.Core.Test.Framework;
namespace NzbDrone.Core.Test.DecisionEngineTests
@ -23,16 +23,16 @@ public class QualityAllowedByProfileSpecificationFixture : CoreTest
public static object[] AllowedTestCases =
{
new object[] { QualityTypes.DVD },
new object[] { QualityTypes.HDTV720p },
new object[] { QualityTypes.Bluray1080p }
new object[] { Quality.DVD },
new object[] { Quality.HDTV720p },
new object[] { Quality.Bluray1080p }
};
public static object[] DeniedTestCases =
{
new object[] { QualityTypes.SDTV },
new object[] { QualityTypes.WEBDL720p },
new object[] { QualityTypes.Bluray720p }
new object[] { Quality.SDTV },
new object[] { Quality.WEBDL720p },
new object[] { Quality.Bluray720p }
};
[SetUp]
@ -41,32 +41,32 @@ public void Setup()
_qualityAllowedByProfile = Mocker.Resolve<QualityAllowedByProfileSpecification>();
var fakeSeries = Builder<Series>.CreateNew()
.With(c => c.QualityProfile = new QualityProfile { Cutoff = QualityTypes.Bluray1080p })
.With(c => c.QualityProfile = new QualityProfile { Cutoff = Quality.Bluray1080p })
.Build();
parseResult = new EpisodeParseResult
{
Series = fakeSeries,
Quality = new QualityModel(QualityTypes.DVD, true),
Quality = new QualityModel(Quality.DVD, true),
EpisodeNumbers = new List<int> { 3 },
SeasonNumber = 12,
};
}
[Test, TestCaseSource("AllowedTestCases")]
public void should_allow_if_quality_is_defined_in_profile(QualityTypes qualityType)
public void should_allow_if_quality_is_defined_in_profile(Quality qualityType)
{
parseResult.Quality.Quality = qualityType;
parseResult.Series.QualityProfile.Allowed = new List<QualityTypes> { QualityTypes.DVD, QualityTypes.HDTV720p, QualityTypes.Bluray1080p };
parseResult.Series.QualityProfile.Allowed = new List<Quality> { Quality.DVD, Quality.HDTV720p, Quality.Bluray1080p };
_qualityAllowedByProfile.IsSatisfiedBy(parseResult).Should().BeTrue();
}
[Test, TestCaseSource("DeniedTestCases")]
public void should_not_allow_if_quality_is_not_defined_in_profile(QualityTypes qualityType)
public void should_not_allow_if_quality_is_not_defined_in_profile(Quality qualityType)
{
parseResult.Quality.Quality = qualityType;
parseResult.Series.QualityProfile.Allowed = new List<QualityTypes> { QualityTypes.DVD, QualityTypes.HDTV720p, QualityTypes.Bluray1080p };
parseResult.Series.QualityProfile.Allowed = new List<Quality> { Quality.DVD, Quality.HDTV720p, Quality.Bluray1080p };
_qualityAllowedByProfile.IsSatisfiedBy(parseResult).Should().BeFalse();
}

View File

@ -3,10 +3,10 @@
using System.Linq;
using FluentAssertions;
using NUnit.Framework;
using NzbDrone.Core.Qualities;
using NzbDrone.Core.Tv;
using NzbDrone.Core.Model;
using NzbDrone.Core.DecisionEngine;
using NzbDrone.Core.Repository.Quality;
using NzbDrone.Core.Test.Framework;
namespace NzbDrone.Core.Test.DecisionEngineTests
@ -17,19 +17,19 @@ public class QualityUpgradeSpecificationFixture : CoreTest
{
public static object[] IsUpgradeTestCases =
{
new object[] { QualityTypes.SDTV, false, QualityTypes.SDTV, true, QualityTypes.SDTV, true },
new object[] { QualityTypes.WEBDL720p, false, QualityTypes.WEBDL720p, true, QualityTypes.WEBDL720p, true },
new object[] { QualityTypes.SDTV, false, QualityTypes.SDTV, false, QualityTypes.SDTV, false },
new object[] { QualityTypes.SDTV, false, QualityTypes.DVD, true, QualityTypes.SDTV, false },
new object[] { QualityTypes.WEBDL720p, false, QualityTypes.HDTV720p, true, QualityTypes.Bluray720p, false },
new object[] { QualityTypes.WEBDL720p, false, QualityTypes.HDTV720p, true, QualityTypes.WEBDL720p, false },
new object[] { QualityTypes.WEBDL720p, false, QualityTypes.WEBDL720p, false, QualityTypes.WEBDL720p, false },
new object[] { QualityTypes.SDTV, false, QualityTypes.SDTV, true, QualityTypes.SDTV, true },
new object[] { QualityTypes.WEBDL1080p, false, QualityTypes.WEBDL1080p, false, QualityTypes.WEBDL1080p, false }
new object[] { Quality.SDTV, false, Quality.SDTV, true, Quality.SDTV, true },
new object[] { Quality.WEBDL720p, false, Quality.WEBDL720p, true, Quality.WEBDL720p, true },
new object[] { Quality.SDTV, false, Quality.SDTV, false, Quality.SDTV, false },
new object[] { Quality.SDTV, false, Quality.DVD, true, Quality.SDTV, false },
new object[] { Quality.WEBDL720p, false, Quality.HDTV720p, true, Quality.Bluray720p, false },
new object[] { Quality.WEBDL720p, false, Quality.HDTV720p, true, Quality.WEBDL720p, false },
new object[] { Quality.WEBDL720p, false, Quality.WEBDL720p, false, Quality.WEBDL720p, false },
new object[] { Quality.SDTV, false, Quality.SDTV, true, Quality.SDTV, true },
new object[] { Quality.WEBDL1080p, false, Quality.WEBDL1080p, false, Quality.WEBDL1080p, false }
};
[Test, TestCaseSource("IsUpgradeTestCases")]
public void IsUpgradeTest(QualityTypes current, bool currentProper, QualityTypes newQuality, bool newProper, QualityTypes cutoff, bool expected)
public void IsUpgradeTest(Quality current, bool currentProper, Quality newQuality, bool newProper, Quality cutoff, bool expected)
{
new QualityUpgradeSpecification().IsSatisfiedBy(new QualityModel(current, currentProper), new QualityModel(newQuality, newProper), cutoff)
.Should().Be(expected);

View File

@ -6,12 +6,12 @@
using FizzWare.NBuilder;
using FluentAssertions;
using NUnit.Framework;
using NzbDrone.Core.Qualities;
using NzbDrone.Core.Tv;
using NzbDrone.Core.Model;
using NzbDrone.Core.Providers;
using NzbDrone.Core.DecisionEngine;
using NzbDrone.Core.Repository;
using NzbDrone.Core.Repository.Quality;
using NzbDrone.Core.Test.Framework;
namespace NzbDrone.Core.Test.DecisionEngineTests
@ -33,20 +33,20 @@ public void Setup()
Mocker.Resolve<QualityUpgradeSpecification>();
_upgradeDisk = Mocker.Resolve<UpgradeDiskSpecification>();
firstFile = new EpisodeFile { Quality = QualityTypes.Bluray1080p, Proper = true, DateAdded = DateTime.Now };
secondFile = new EpisodeFile { Quality = QualityTypes.Bluray1080p, Proper = true, DateAdded = DateTime.Now };
firstFile = new EpisodeFile { Quality = Quality.Bluray1080p, Proper = true, DateAdded = DateTime.Now };
secondFile = new EpisodeFile { Quality = Quality.Bluray1080p, Proper = true, DateAdded = DateTime.Now };
var singleEpisodeList = new List<Episode> { new Episode { EpisodeFile = firstFile }, new Episode { EpisodeFile = null } };
var doubleEpisodeList = new List<Episode> { new Episode { EpisodeFile = firstFile }, new Episode { EpisodeFile = secondFile }, new Episode { EpisodeFile = null } };
var fakeSeries = Builder<Series>.CreateNew()
.With(c => c.QualityProfile = new QualityProfile { Cutoff = QualityTypes.Bluray1080p })
.With(c => c.QualityProfile = new QualityProfile { Cutoff = Quality.Bluray1080p })
.Build();
parseResultMulti = new EpisodeParseResult
{
Series = fakeSeries,
Quality = new QualityModel(QualityTypes.DVD, true),
Quality = new QualityModel(Quality.DVD, true),
EpisodeNumbers = new List<int> { 3, 4 },
SeasonNumber = 12,
Episodes = doubleEpisodeList
@ -55,7 +55,7 @@ public void Setup()
parseResultSingle = new EpisodeParseResult
{
Series = fakeSeries,
Quality = new QualityModel(QualityTypes.DVD, true),
Quality = new QualityModel(Quality.DVD, true),
EpisodeNumbers = new List<int> { 3 },
SeasonNumber = 12,
Episodes = singleEpisodeList
@ -64,12 +64,12 @@ public void Setup()
private void WithFirstFileUpgradable()
{
firstFile.Quality = QualityTypes.SDTV;
firstFile.Quality = Quality.SDTV;
}
private void WithSecondFileUpgradable()
{
secondFile.Quality = QualityTypes.SDTV;
secondFile.Quality = Quality.SDTV;
}
[Test]
@ -118,9 +118,9 @@ public void should_be_not_upgradable_if_only_second_episodes_is_upgradable()
[Test]
public void should_not_be_upgradable_if_qualities_are_the_same()
{
firstFile.Quality = QualityTypes.WEBDL1080p;
firstFile.Quality = Quality.WEBDL1080p;
firstFile.Proper = false;
parseResultSingle.Quality = new QualityModel(QualityTypes.WEBDL1080p, false);
parseResultSingle.Quality = new QualityModel(Quality.WEBDL1080p, false);
_upgradeDisk.IsSatisfiedBy(parseResultSingle).Should().BeFalse();
}

View File

@ -6,12 +6,12 @@
using FluentAssertions;
using NUnit.Framework;
using NzbDrone.Core.History;
using NzbDrone.Core.Qualities;
using NzbDrone.Core.Tv;
using NzbDrone.Core.Model;
using NzbDrone.Core.Providers;
using NzbDrone.Core.DecisionEngine;
using NzbDrone.Core.Repository;
using NzbDrone.Core.Repository.Quality;
using NzbDrone.Core.Test.Framework;
namespace NzbDrone.Core.Test.DecisionEngineTests
@ -42,13 +42,13 @@ public void Setup()
};
fakeSeries = Builder<Series>.CreateNew()
.With(c => c.QualityProfile = new QualityProfile { Cutoff = QualityTypes.Bluray1080p })
.With(c => c.QualityProfile = new QualityProfile { Cutoff = Quality.Bluray1080p })
.Build();
parseResultMulti = new EpisodeParseResult
{
Series = fakeSeries,
Quality = new QualityModel(QualityTypes.DVD, true),
Quality = new QualityModel(Quality.DVD, true),
EpisodeNumbers = new List<int> { 3, 4 },
SeasonNumber = 12,
Episodes = doubleEpisodeList
@ -57,14 +57,14 @@ public void Setup()
parseResultSingle = new EpisodeParseResult
{
Series = fakeSeries,
Quality = new QualityModel(QualityTypes.DVD, true),
Quality = new QualityModel(Quality.DVD, true),
EpisodeNumbers = new List<int> { 3 },
SeasonNumber = 12,
Episodes = singleEpisodeList
};
firstQuality = new QualityModel(QualityTypes.Bluray1080p, true);
secondQuality = new QualityModel(QualityTypes.Bluray1080p, true);
firstQuality = new QualityModel(Quality.Bluray1080p, true);
secondQuality = new QualityModel(Quality.Bluray1080p, true);
Mocker.GetMock<IHistoryService>().Setup(c => c.GetBestQualityInHistory(fakeSeries.Id, 12, 3)).Returns(firstQuality);
Mocker.GetMock<IHistoryService>().Setup(c => c.GetBestQualityInHistory(fakeSeries.Id, 12, 4)).Returns(secondQuality);
@ -73,12 +73,12 @@ public void Setup()
private void WithFirstReportUpgradable()
{
firstQuality.Quality = QualityTypes.SDTV;
firstQuality.Quality = Quality.SDTV;
}
private void WithSecondReportUpgradable()
{
secondQuality.Quality = QualityTypes.SDTV;
secondQuality.Quality = Quality.SDTV;
}
@ -120,9 +120,9 @@ public void should_be_not_upgradable_if_only_second_episodes_is_upgradable()
[Test]
public void should_not_be_upgradable_if_episode_is_of_same_quality_as_existing()
{
fakeSeries.QualityProfile = new QualityProfile { Cutoff = QualityTypes.WEBDL1080p };
parseResultSingle.Quality = new QualityModel(QualityTypes.WEBDL1080p, false);
firstQuality = new QualityModel(QualityTypes.WEBDL1080p, false);
fakeSeries.QualityProfile = new QualityProfile { Cutoff = Quality.WEBDL1080p };
parseResultSingle.Quality = new QualityModel(Quality.WEBDL1080p, false);
firstQuality = new QualityModel(Quality.WEBDL1080p, false);
Mocker.GetMock<IHistoryService>().Setup(c => c.GetBestQualityInHistory(fakeSeries.Id, 12, 3)).Returns(firstQuality);

View File

@ -5,11 +5,11 @@
using FluentAssertions;
using Moq;
using NUnit.Framework;
using NzbDrone.Core.Qualities;
using NzbDrone.Core.Tv;
using NzbDrone.Core.Providers;
using NzbDrone.Core.DecisionEngine;
using NzbDrone.Core.Repository;
using NzbDrone.Core.Repository.Quality;
using NzbDrone.Core.Test.Framework;
namespace NzbDrone.Core.Test.DecisionEngineTests
@ -20,8 +20,8 @@ public class UpgradePossibleSpecificationFixture : CoreTest
{
private void WithWebdlCutoff()
{
var profile = new QualityProfile { Cutoff = QualityTypes.WEBDL720p };
Mocker.GetMock<QualityProvider>().Setup(s => s.Get(It.IsAny<int>())).Returns(profile);
var profile = new QualityProfile { Cutoff = Quality.WEBDL720p };
Mocker.GetMock<QualityProfileService>().Setup(s => s.Get(It.IsAny<int>())).Returns(profile);
}
private Series _series;
@ -35,7 +35,7 @@ public void SetUp()
.Build();
_episodeFile = Builder<EpisodeFile>.CreateNew()
.With(f => f.Quality = QualityTypes.SDTV)
.With(f => f.Quality = Quality.SDTV)
.Build();
_episode = Builder<Episode>.CreateNew()
@ -76,7 +76,7 @@ public void IsUpgradePossible_should_return_false_if_current_episode_is_equal_to
{
WithWebdlCutoff();
_episodeFile.Quality = QualityTypes.WEBDL720p;
_episodeFile.Quality = Quality.WEBDL720p;
//Act
bool result = Mocker.Resolve<UpgradePossibleSpecification>().IsSatisfiedBy(_episode);
@ -90,7 +90,7 @@ public void IsUpgradePossible_should_return_false_if_current_episode_is_greater_
{
WithWebdlCutoff();
_episodeFile.Quality = QualityTypes.Bluray720p;
_episodeFile.Quality = Quality.Bluray720p;
//Act
bool result = Mocker.Resolve<UpgradePossibleSpecification>().IsSatisfiedBy(_episode);

View File

@ -4,9 +4,9 @@
using FizzWare.NBuilder;
using FluentAssertions;
using NUnit.Framework;
using NzbDrone.Core.Qualities;
using NzbDrone.Core.Tv;
using NzbDrone.Core.Model;
using NzbDrone.Core.Repository.Quality;
using NzbDrone.Core.Test.Framework;
namespace NzbDrone.Core.Test
@ -24,7 +24,7 @@ public void tostring_single_season_episode()
parseResult.EpisodeNumbers = new List<int> { 3 };
parseResult.FullSeason = false;
parseResult.AirDate = null;
parseResult.Quality = new QualityModel(QualityTypes.HDTV720p, false);
parseResult.Quality = new QualityModel(Quality.HDTV720p, false);
parseResult.ToString().Should().Be("My Series - S12E03 HDTV-720p");
@ -39,7 +39,7 @@ public void tostring_single_season_episode_proper()
parseResult.EpisodeNumbers = new List<int> { 3 };
parseResult.FullSeason = false;
parseResult.AirDate = null;
parseResult.Quality = new QualityModel(QualityTypes.HDTV720p, true);
parseResult.Quality = new QualityModel(Quality.HDTV720p, true);
parseResult.ToString().Should().Be("My Series - S12E03 HDTV-720p [proper]");
@ -54,7 +54,7 @@ public void tostring_multi_season_episode()
parseResult.EpisodeNumbers = new List<int> { 3, 4, 5 };
parseResult.FullSeason = false;
parseResult.AirDate = null;
parseResult.Quality = new QualityModel(QualityTypes.HDTV720p, false);
parseResult.Quality = new QualityModel(Quality.HDTV720p, false);
parseResult.ToString().Should().Be("My Series - S12E03-04-05 HDTV-720p");
@ -69,7 +69,7 @@ public void tostring_multi_season_episode_proper()
parseResult.EpisodeNumbers = new List<int> { 3, 4, 5 };
parseResult.FullSeason = false;
parseResult.AirDate = null;
parseResult.Quality = new QualityModel(QualityTypes.HDTV720p, true);
parseResult.Quality = new QualityModel(Quality.HDTV720p, true);
parseResult.ToString().Should().Be("My Series - S12E03-04-05 HDTV-720p [proper]");
@ -84,7 +84,7 @@ public void tostring_full_season()
parseResult.SeasonNumber = 12;
parseResult.FullSeason = true;
parseResult.AirDate = null;
parseResult.Quality = new QualityModel(QualityTypes.HDTV720p, false);
parseResult.Quality = new QualityModel(Quality.HDTV720p, false);
parseResult.ToString().Should().Be("My Series - Season 12 HDTV-720p");
@ -99,7 +99,7 @@ public void tostring_full_season_proper()
parseResult.SeasonNumber = 12;
parseResult.FullSeason = true;
parseResult.AirDate = null;
parseResult.Quality = new QualityModel(QualityTypes.HDTV720p, true);
parseResult.Quality = new QualityModel(Quality.HDTV720p, true);
parseResult.ToString().Should().Be("My Series - Season 12 HDTV-720p [proper]");
@ -113,7 +113,7 @@ public void tostring_daily_show()
parseResult.SeasonNumber = 12;
parseResult.FullSeason = true;
parseResult.AirDate = new DateTime(2010, 12, 30);
parseResult.Quality = new QualityModel(QualityTypes.HDTV720p, false);
parseResult.Quality = new QualityModel(Quality.HDTV720p, false);
parseResult.ToString().Should().Be("My Series - 2010-12-30 HDTV-720p");
@ -127,7 +127,7 @@ public void tostring_daily_show_proper()
parseResult.SeasonNumber = 12;
parseResult.FullSeason = true;
parseResult.AirDate = new DateTime(2010, 12, 30);
parseResult.Quality = new QualityModel(QualityTypes.HDTV720p, true);
parseResult.Quality = new QualityModel(Quality.HDTV720p, true);
parseResult.ToString().Should().Be("My Series - 2010-12-30 HDTV-720p [proper]");
@ -137,17 +137,17 @@ public void tostring_daily_show_proper()
public static readonly object[] SabNamingCases =
{
new object[] { 1, new[] { 2 }, "My Episode Title", QualityTypes.DVD, false, "My Series Name - 1x02 - My Episode Title [DVD]" },
new object[] { 1, new[] { 2 }, "My Episode Title", QualityTypes.DVD, true, "My Series Name - 1x02 - My Episode Title [DVD] [Proper]" },
new object[] { 1, new[] { 2 }, "", QualityTypes.DVD, true, "My Series Name - 1x02 - [DVD] [Proper]" },
new object[] { 1, new[] { 2, 4 }, "My Episode Title", QualityTypes.HDTV720p, false, "My Series Name - 1x02-1x04 - My Episode Title [HDTV-720p]" },
new object[] { 1, new[] { 2, 4 }, "My Episode Title", QualityTypes.HDTV720p, true, "My Series Name - 1x02-1x04 - My Episode Title [HDTV-720p] [Proper]" },
new object[] { 1, new[] { 2, 4 }, "", QualityTypes.HDTV720p, true, "My Series Name - 1x02-1x04 - [HDTV-720p] [Proper]" },
new object[] { 1, new[] { 2 }, "My Episode Title", Quality.DVD, false, "My Series Name - 1x02 - My Episode Title [DVD]" },
new object[] { 1, new[] { 2 }, "My Episode Title", Quality.DVD, true, "My Series Name - 1x02 - My Episode Title [DVD] [Proper]" },
new object[] { 1, new[] { 2 }, "", Quality.DVD, true, "My Series Name - 1x02 - [DVD] [Proper]" },
new object[] { 1, new[] { 2, 4 }, "My Episode Title", Quality.HDTV720p, false, "My Series Name - 1x02-1x04 - My Episode Title [HDTV-720p]" },
new object[] { 1, new[] { 2, 4 }, "My Episode Title", Quality.HDTV720p, true, "My Series Name - 1x02-1x04 - My Episode Title [HDTV-720p] [Proper]" },
new object[] { 1, new[] { 2, 4 }, "", Quality.HDTV720p, true, "My Series Name - 1x02-1x04 - [HDTV-720p] [Proper]" },
};
[Test, TestCaseSource("SabNamingCases")]
public void create_proper_sab_titles(int seasons, int[] episodes, string title, QualityTypes quality, bool proper, string expected)
public void create_proper_sab_titles(int seasons, int[] episodes, string title, Quality quality, bool proper, string expected)
{
var series = Builder<Series>.CreateNew()
.With(c => c.Title = "My Series Name")
@ -187,7 +187,7 @@ public string create_proper_sab_season_title(bool proper)
var parsResult = new EpisodeParseResult()
{
AirDate = DateTime.Now,
Quality = new QualityModel(QualityTypes.Bluray720p, proper),
Quality = new QualityModel(Quality.Bluray720p, proper),
SeasonNumber = 1,
Series = series,
EpisodeTitle = "My Episode Title",
@ -213,7 +213,7 @@ public string create_proper_sab_daily_titles(bool proper)
var parsResult = new EpisodeParseResult
{
AirDate = new DateTime(2011, 12, 1),
Quality = new QualityModel(QualityTypes.Bluray720p, proper),
Quality = new QualityModel(Quality.Bluray720p, proper),
Series = series,
EpisodeTitle = "My Episode Title",
Episodes = new List<Episode> { episode }
@ -242,7 +242,7 @@ public void should_not_repeat_the_same_episode_title()
{
AirDate = DateTime.Now,
EpisodeNumbers = new List<int> { 10, 11 },
Quality = new QualityModel(QualityTypes.HDTV720p, false),
Quality = new QualityModel(Quality.HDTV720p, false),
SeasonNumber = 35,
Series = series,
Episodes = fakeEpisodes

View File

@ -9,7 +9,6 @@
using NzbDrone.Core.Datastore;
using NzbDrone.Core.Providers.Core;
using NzbDrone.Core.Repository;
using NzbDrone.Core.Repository.Quality;
using PetaPoco;
namespace NzbDrone.Core.Test.Framework

View File

@ -5,8 +5,8 @@
using NUnit.Framework;
using NzbDrone.Core.Datastore;
using NzbDrone.Core.History;
using NzbDrone.Core.Qualities;
using NzbDrone.Core.Tv;
using NzbDrone.Core.Repository.Quality;
using NzbDrone.Core.Test.Framework;
namespace NzbDrone.Core.Test.HistoryTests
@ -53,7 +53,7 @@ public void GetBestQualityInHistory_single_result()
var history = Builder<History.History>.CreateNew()
.With(c => c.Id = 0)
.With(h => h.Quality = new QualityModel(QualityTypes.Bluray720p, true))
.With(h => h.Quality = new QualityModel(Quality.Bluray720p, true))
.With(h => h.Episode = episode)
.Build();
@ -62,7 +62,7 @@ public void GetBestQualityInHistory_single_result()
var result = Subject.GetBestQualityInHistory(episode.SeriesId, episode.SeasonNumber, episode.EpisodeNumber);
result.Should().NotBeNull();
result.Quality.Should().Be(QualityTypes.Bluray720p);
result.Quality.Should().Be(Quality.Bluray720p);
result.Proper.Should().BeTrue();
}
@ -83,15 +83,15 @@ public void GetBestQualityInHistory_should_return_highest_result()
.With(c => c.Id = 0)
.With(h => h.Episode = episode)
.TheFirst(1)
.With(h => h.Quality = new QualityModel(QualityTypes.DVD, true))
.With(h => h.Quality = new QualityModel(Quality.DVD, true))
.TheNext(1)
.With(h => h.Quality = new QualityModel(QualityTypes.Bluray720p, true))
.With(h => h.Quality = new QualityModel(Quality.Bluray720p, true))
.TheNext(1)
.With(h => h.Quality = new QualityModel(QualityTypes.Bluray720p, true))
.With(h => h.Quality = new QualityModel(Quality.Bluray720p, true))
.TheNext(1)
.With(h => h.Quality = new QualityModel(QualityTypes.Bluray720p, false))
.With(h => h.Quality = new QualityModel(Quality.Bluray720p, false))
.TheNext(1)
.With(h => h.Quality = new QualityModel(QualityTypes.SDTV, true))
.With(h => h.Quality = new QualityModel(Quality.SDTV, true))
.Build();
Db.InsertMany(history);
@ -99,7 +99,7 @@ public void GetBestQualityInHistory_should_return_highest_result()
var result = Subject.GetBestQualityInHistory(episode.SeriesId, episode.SeasonNumber, episode.EpisodeNumber);
result.Should().NotBeNull();
result.Quality.Should().Be(QualityTypes.Bluray720p);
result.Quality.Should().Be(Quality.Bluray720p);
result.Proper.Should().BeTrue();
}

View File

@ -15,8 +15,8 @@
using NzbDrone.Core.Model;
using NzbDrone.Core.Providers;
using NzbDrone.Core.Providers.Core;
using NzbDrone.Core.Qualities;
using NzbDrone.Core.Repository;
using NzbDrone.Core.Repository.Quality;
using NzbDrone.Core.Test.Framework;
using NzbDrone.Core.Test.Indexers;
using NzbDrone.Core.Test.ProviderTests;
@ -82,7 +82,7 @@ public void custom_parser_partial_success()
const string title = "Adventure.Inc.S03E19.DVDRip.XviD-OSiTV";
const int season = 3;
const int episode = 19;
var quality = QualityTypes.DVD;
var quality = Quality.DVD;
const string summary = "My fake summary";

View File

@ -15,7 +15,6 @@
using NzbDrone.Core.Providers;
using NzbDrone.Core.Providers.Core;
using NzbDrone.Core.Repository;
using NzbDrone.Core.Repository.Quality;
using NzbDrone.Core.Test.Framework;
using NzbDrone.Core.Test.ProviderTests;
using NzbDrone.Test.Common;

View File

@ -164,7 +164,7 @@
<Compile Include="HelperTests\XElementHelperTests\ConvertToDayOfWeekFixture.cs" />
<Compile Include="ProviderTests\TvRageProviderTests\GetUtcOffsetFixture.cs" />
<Compile Include="ProviderTests\TvRageProviderTests\SearchSeriesFixture.cs" />
<Compile Include="QualityTypesTest.cs" />
<Compile Include="Qualities\QualityFixture.cs" />
<Compile Include="EpisodeParseResultTest.cs" />
<Compile Include="JobTests\BacklogSearchJobTest.cs" />
<Compile Include="JobTests\BannerDownloadJobTest.cs" />
@ -220,7 +220,7 @@
<Compile Include="Services\ParseErrorServiceFixture.cs" />
<Compile Include="HelperTests\SortHelperFixture.cs" />
<Compile Include="DecisionEngineTests\AcceptableSizeSpecificationFixture.cs" />
<Compile Include="ProviderTests\QualityTypeProviderTest.cs" />
<Compile Include="Qualities\QualitySizeServiceFixture.cs" />
<Compile Include="ProviderTests\MisnamedProviderTest.cs" />
<Compile Include="JobTests\SeasonSearchJobTest.cs" />
<Compile Include="JobTests\SeriesSearchJobTest.cs" />
@ -243,7 +243,7 @@
<Compile Include="IndexerTests\IndexerFixture.cs" />
<Compile Include="DecisionEngineTests\AllowedDownloadSpecificationFixture.cs" />
<Compile Include="JobTests\JobControllerFixture.cs" />
<Compile Include="QualityTest.cs" />
<Compile Include="TvTests\QualityModelFixture.cs" />
<Compile Include="RootFolderTests\RootFolderServiceFixture.cs" />
<Compile Include="Indexers\IndexerServiceTest.cs" />
<Compile Include="HistoryTests\HistoryServiceTest.cs" />
@ -253,7 +253,7 @@
<Compile Include="Framework\TestDbHelper.cs" />
<Compile Include="ParserTests\ParserFixture.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="QualityProfileTest.cs" />
<Compile Include="Qualities\QualityProfileFixture.cs" />
<Compile Include="ProviderTests\DownloadClientTests\SabProviderTests\SabProviderFixture.cs" />
<Compile Include="ProviderTests\SceneMappingProviderTest.cs" />
<Compile Include="TvTests\SeriesProviderTest.cs" />

View File

@ -4,7 +4,7 @@
using System.Linq;
using FluentAssertions;
using NUnit.Framework;
using NzbDrone.Core.Repository.Quality;
using NzbDrone.Core.Qualities;
using NzbDrone.Core.Test.Framework;
namespace NzbDrone.Core.Test.ParserTests
@ -15,86 +15,86 @@ public class QualityParserFixture : CoreTest
{
public static object[] QualityParserCases =
{
new object[] { "WEEDS.S03E01-06.DUAL.BDRip.XviD.AC3.-HELLYWOOD", QualityTypes.DVD, false },
new object[] { "WEEDS.S03E01-06.DUAL.BDRip.X-viD.AC3.-HELLYWOOD", QualityTypes.DVD, false },
new object[] { "WEEDS.S03E01-06.DUAL.BDRip.AC3.-HELLYWOOD", QualityTypes.DVD, false },
new object[] { "Two.and.a.Half.Men.S08E05.720p.HDTV.X264-DIMENSION", QualityTypes.HDTV720p, false },
new object[] { "this has no extention or periods HDTV", QualityTypes.SDTV, false },
new object[] { "Chuck.S04E05.HDTV.XviD-LOL", QualityTypes.SDTV, false },
new object[] { "The.Girls.Next.Door.S03E06.DVDRip.XviD-WiDE", QualityTypes.DVD, false },
new object[] { "The.Girls.Next.Door.S03E06.DVD.Rip.XviD-WiDE", QualityTypes.DVD, false },
new object[] { "The.Girls.Next.Door.S03E06.HDTV-WiDE", QualityTypes.SDTV, false },
new object[] { "Degrassi.S10E27.WS.DSR.XviD-2HD", QualityTypes.SDTV, false },
new object[] { "Sonny.With.a.Chance.S02E15.720p.WEB-DL.DD5.1.H.264-SURFER", QualityTypes.WEBDL720p, false },
new object[] { "Sonny.With.a.Chance.S02E15.720p", QualityTypes.HDTV720p, false },
new object[] { "Sonny.With.a.Chance.S02E15.mkv", QualityTypes.HDTV720p, false },
new object[] { "Sonny.With.a.Chance.S02E15.avi", QualityTypes.SDTV, false },
new object[] { "Sonny.With.a.Chance.S02E15.xvid", QualityTypes.SDTV, false },
new object[] { "Sonny.With.a.Chance.S02E15.divx", QualityTypes.SDTV, false },
new object[] { "Sonny.With.a.Chance.S02E15", QualityTypes.Unknown, false },
new object[] { "Chuck - S01E04 - So Old - Playdate - 720p TV.mkv", QualityTypes.HDTV720p, false },
new object[] { "Chuck - S22E03 - MoneyBART - HD TV.mkv", QualityTypes.HDTV720p, false },
new object[] { "Chuck - S01E03 - Come Fly With Me - 720p BluRay.mkv", QualityTypes.Bluray720p, false },
new object[] { "Chuck - S01E03 - Come Fly With Me - 1080p BluRay.mkv", QualityTypes.Bluray1080p, false },
new object[] { "Chuck - S11E06 - D-Yikes! - 720p WEB-DL.mkv", QualityTypes.WEBDL720p, false },
new object[] { "WEEDS.S03E01-06.DUAL.BDRip.XviD.AC3.-HELLYWOOD.avi", QualityTypes.DVD, false },
new object[] { "WEEDS.S03E01-06.DUAL.BDRip.XviD.AC3.-HELLYWOOD.avi", QualityTypes.DVD, false },
new object[] { "Law & Order: Special Victims Unit - 11x11 - Quickie", QualityTypes.Unknown, false },
new object[] { "(<a href=\"http://www.newzbin.com/browse/post/6076286/nzb/\">NZB</a>)", QualityTypes.Unknown, false },
new object[] { "S07E23 - [HDTV-720p].mkv ", QualityTypes.HDTV720p, false },
new object[] { "S07E23 - [WEBDL].mkv ", QualityTypes.WEBDL720p, false },
new object[] { "S07E23.mkv ", QualityTypes.HDTV720p, false },
new object[] { "S07E23 .avi ", QualityTypes.SDTV, false },
new object[] { "WEEDS.S03E01-06.DUAL.XviD.Bluray.AC3.-HELLYWOOD.avi", QualityTypes.DVD, false },
new object[] { "WEEDS.S03E01-06.DUAL.Bluray.AC3.-HELLYWOOD.avi", QualityTypes.Bluray720p, false },
new object[] { "The Voice S01E11 The Finals 1080i HDTV DD5.1 MPEG2-TrollHD", QualityTypes.RAWHD, false },
new object[] { "Nikita S02E01 HDTV XviD 2HD", QualityTypes.SDTV, false },
new object[] { "Gossip Girl S05E11 PROPER HDTV XviD 2HD", QualityTypes.SDTV, true },
new object[] { "The Jonathan Ross Show S02E08 HDTV x264 FTP", QualityTypes.SDTV, false },
new object[] { "White.Van.Man.2011.S02E01.WS.PDTV.x264-TLA", QualityTypes.SDTV, false },
new object[] { "White.Van.Man.2011.S02E01.WS.PDTV.x264-REPACK-TLA", QualityTypes.SDTV, true },
new object[] { "WEEDS.S03E01-06.DUAL.XviD.Bluray.AC3-REPACK.-HELLYWOOD.avi", QualityTypes.DVD, true },
new object[] { "Pawn Stars S04E87 REPACK 720p HDTV x264 aAF", QualityTypes.HDTV720p, true },
new object[] { "The Real Housewives of Vancouver S01E04 DSR x264 2HD", QualityTypes.SDTV, false },
new object[] { "Vanguard S01E04 Mexicos Death Train DSR x264 MiNDTHEGAP", QualityTypes.SDTV, false },
new object[] { "Vanguard S01E04 Mexicos Death Train 720p WEB DL", QualityTypes.WEBDL720p, false },
new object[] { "Hawaii Five 0 S02E21 720p WEB DL DD5 1 H 264", QualityTypes.WEBDL720p, false },
new object[] { "Castle S04E22 720p WEB DL DD5 1 H 264 NFHD", QualityTypes.WEBDL720p, false },
new object[] { "Fringe S04E22 720p WEB-DL DD5.1 H264-EbP.mkv", QualityTypes.WEBDL720p, false },
new object[] { "CSI NY S09E03 1080p WEB DL DD5 1 H264 NFHD", QualityTypes.WEBDL1080p, false },
new object[] { "Two and a Half Men S10E03 1080p WEB DL DD5 1 H 264 NFHD", QualityTypes.WEBDL1080p, false },
new object[] { "Criminal.Minds.S08E01.1080p.WEB-DL.DD5.1.H264-NFHD", QualityTypes.WEBDL1080p, false },
new object[] { "Its.Always.Sunny.in.Philadelphia.S08E01.1080p.WEB-DL.proper.AAC2.0.H.264", QualityTypes.WEBDL1080p, true },
new object[] { "Two and a Half Men S10E03 1080p WEB DL DD5 1 H 264 REPACK NFHD", QualityTypes.WEBDL1080p, true },
new object[] { "Glee.S04E09.Swan.Song.1080p.WEB-DL.DD5.1.H.264-ECI", QualityTypes.WEBDL1080p, false },
new object[] { "Elementary.S01E10.The.Leviathan.480p.WEB-DL.x264-mSD", QualityTypes.WEBDL480p, false },
new object[] { "Glee.S04E10.Glee.Actually.480p.WEB-DL.x264-mSD", QualityTypes.WEBDL480p, false },
new object[] { "The.Big.Bang.Theory.S06E11.The.Santa.Simulation.480p.WEB-DL.x264-mSD", QualityTypes.WEBDL480p, false },
new object[] { "The.Big.Bang.Theory.S06E11.The.Santa.Simulation.1080p.WEB-DL.DD5.1.H.264", QualityTypes.WEBDL1080p, false },
new object[] { "DEXTER.S07E01.ARE.YOU.1080P.HDTV.X264-QCF", QualityTypes.HDTV1080p, false },
new object[] { "DEXTER.S07E01.ARE.YOU.1080P.HDTV.x264-QCF", QualityTypes.HDTV1080p, false },
new object[] { "DEXTER.S07E01.ARE.YOU.1080P.HDTV.proper.X264-QCF", QualityTypes.HDTV1080p, true },
new object[] { "Dexter - S01E01 - Title [HDTV]", QualityTypes.HDTV720p, false },
new object[] { "Dexter - S01E01 - Title [HDTV-720p]", QualityTypes.HDTV720p, false },
new object[] { "Dexter - S01E01 - Title [HDTV-1080p]", QualityTypes.HDTV1080p, false },
new object[] { "POI S02E11 1080i HDTV DD5.1 MPEG2-TrollHD", QualityTypes.RAWHD, false },
new object[] { "How I Met Your Mother S01E18 Nothing Good Happens After 2 A.M. 720p HDTV DD5.1 MPEG2-TrollHD", QualityTypes.RAWHD, false }
new object[] { "WEEDS.S03E01-06.DUAL.BDRip.XviD.AC3.-HELLYWOOD", Quality.DVD, false },
new object[] { "WEEDS.S03E01-06.DUAL.BDRip.X-viD.AC3.-HELLYWOOD", Quality.DVD, false },
new object[] { "WEEDS.S03E01-06.DUAL.BDRip.AC3.-HELLYWOOD", Quality.DVD, false },
new object[] { "Two.and.a.Half.Men.S08E05.720p.HDTV.X264-DIMENSION", Quality.HDTV720p, false },
new object[] { "this has no extention or periods HDTV", Quality.SDTV, false },
new object[] { "Chuck.S04E05.HDTV.XviD-LOL", Quality.SDTV, false },
new object[] { "The.Girls.Next.Door.S03E06.DVDRip.XviD-WiDE", Quality.DVD, false },
new object[] { "The.Girls.Next.Door.S03E06.DVD.Rip.XviD-WiDE", Quality.DVD, false },
new object[] { "The.Girls.Next.Door.S03E06.HDTV-WiDE", Quality.SDTV, false },
new object[] { "Degrassi.S10E27.WS.DSR.XviD-2HD", Quality.SDTV, false },
new object[] { "Sonny.With.a.Chance.S02E15.720p.WEB-DL.DD5.1.H.264-SURFER", Quality.WEBDL720p, false },
new object[] { "Sonny.With.a.Chance.S02E15.720p", Quality.HDTV720p, false },
new object[] { "Sonny.With.a.Chance.S02E15.mkv", Quality.HDTV720p, false },
new object[] { "Sonny.With.a.Chance.S02E15.avi", Quality.SDTV, false },
new object[] { "Sonny.With.a.Chance.S02E15.xvid", Quality.SDTV, false },
new object[] { "Sonny.With.a.Chance.S02E15.divx", Quality.SDTV, false },
new object[] { "Sonny.With.a.Chance.S02E15", Quality.Unknown, false },
new object[] { "Chuck - S01E04 - So Old - Playdate - 720p TV.mkv", Quality.HDTV720p, false },
new object[] { "Chuck - S22E03 - MoneyBART - HD TV.mkv", Quality.HDTV720p, false },
new object[] { "Chuck - S01E03 - Come Fly With Me - 720p BluRay.mkv", Quality.Bluray720p, false },
new object[] { "Chuck - S01E03 - Come Fly With Me - 1080p BluRay.mkv", Quality.Bluray1080p, false },
new object[] { "Chuck - S11E06 - D-Yikes! - 720p WEB-DL.mkv", Quality.WEBDL720p, false },
new object[] { "WEEDS.S03E01-06.DUAL.BDRip.XviD.AC3.-HELLYWOOD.avi", Quality.DVD, false },
new object[] { "WEEDS.S03E01-06.DUAL.BDRip.XviD.AC3.-HELLYWOOD.avi", Quality.DVD, false },
new object[] { "Law & Order: Special Victims Unit - 11x11 - Quickie", Quality.Unknown, false },
new object[] { "(<a href=\"http://www.newzbin.com/browse/post/6076286/nzb/\">NZB</a>)", Quality.Unknown, false },
new object[] { "S07E23 - [HDTV-720p].mkv ", Quality.HDTV720p, false },
new object[] { "S07E23 - [WEBDL].mkv ", Quality.WEBDL720p, false },
new object[] { "S07E23.mkv ", Quality.HDTV720p, false },
new object[] { "S07E23 .avi ", Quality.SDTV, false },
new object[] { "WEEDS.S03E01-06.DUAL.XviD.Bluray.AC3.-HELLYWOOD.avi", Quality.DVD, false },
new object[] { "WEEDS.S03E01-06.DUAL.Bluray.AC3.-HELLYWOOD.avi", Quality.Bluray720p, false },
new object[] { "The Voice S01E11 The Finals 1080i HDTV DD5.1 MPEG2-TrollHD", Quality.RAWHD, false },
new object[] { "Nikita S02E01 HDTV XviD 2HD", Quality.SDTV, false },
new object[] { "Gossip Girl S05E11 PROPER HDTV XviD 2HD", Quality.SDTV, true },
new object[] { "The Jonathan Ross Show S02E08 HDTV x264 FTP", Quality.SDTV, false },
new object[] { "White.Van.Man.2011.S02E01.WS.PDTV.x264-TLA", Quality.SDTV, false },
new object[] { "White.Van.Man.2011.S02E01.WS.PDTV.x264-REPACK-TLA", Quality.SDTV, true },
new object[] { "WEEDS.S03E01-06.DUAL.XviD.Bluray.AC3-REPACK.-HELLYWOOD.avi", Quality.DVD, true },
new object[] { "Pawn Stars S04E87 REPACK 720p HDTV x264 aAF", Quality.HDTV720p, true },
new object[] { "The Real Housewives of Vancouver S01E04 DSR x264 2HD", Quality.SDTV, false },
new object[] { "Vanguard S01E04 Mexicos Death Train DSR x264 MiNDTHEGAP", Quality.SDTV, false },
new object[] { "Vanguard S01E04 Mexicos Death Train 720p WEB DL", Quality.WEBDL720p, false },
new object[] { "Hawaii Five 0 S02E21 720p WEB DL DD5 1 H 264", Quality.WEBDL720p, false },
new object[] { "Castle S04E22 720p WEB DL DD5 1 H 264 NFHD", Quality.WEBDL720p, false },
new object[] { "Fringe S04E22 720p WEB-DL DD5.1 H264-EbP.mkv", Quality.WEBDL720p, false },
new object[] { "CSI NY S09E03 1080p WEB DL DD5 1 H264 NFHD", Quality.WEBDL1080p, false },
new object[] { "Two and a Half Men S10E03 1080p WEB DL DD5 1 H 264 NFHD", Quality.WEBDL1080p, false },
new object[] { "Criminal.Minds.S08E01.1080p.WEB-DL.DD5.1.H264-NFHD", Quality.WEBDL1080p, false },
new object[] { "Its.Always.Sunny.in.Philadelphia.S08E01.1080p.WEB-DL.proper.AAC2.0.H.264", Quality.WEBDL1080p, true },
new object[] { "Two and a Half Men S10E03 1080p WEB DL DD5 1 H 264 REPACK NFHD", Quality.WEBDL1080p, true },
new object[] { "Glee.S04E09.Swan.Song.1080p.WEB-DL.DD5.1.H.264-ECI", Quality.WEBDL1080p, false },
new object[] { "Elementary.S01E10.The.Leviathan.480p.WEB-DL.x264-mSD", Quality.WEBDL480p, false },
new object[] { "Glee.S04E10.Glee.Actually.480p.WEB-DL.x264-mSD", Quality.WEBDL480p, false },
new object[] { "The.Big.Bang.Theory.S06E11.The.Santa.Simulation.480p.WEB-DL.x264-mSD", Quality.WEBDL480p, false },
new object[] { "The.Big.Bang.Theory.S06E11.The.Santa.Simulation.1080p.WEB-DL.DD5.1.H.264", Quality.WEBDL1080p, false },
new object[] { "DEXTER.S07E01.ARE.YOU.1080P.HDTV.X264-QCF", Quality.HDTV1080p, false },
new object[] { "DEXTER.S07E01.ARE.YOU.1080P.HDTV.x264-QCF", Quality.HDTV1080p, false },
new object[] { "DEXTER.S07E01.ARE.YOU.1080P.HDTV.proper.X264-QCF", Quality.HDTV1080p, true },
new object[] { "Dexter - S01E01 - Title [HDTV]", Quality.HDTV720p, false },
new object[] { "Dexter - S01E01 - Title [HDTV-720p]", Quality.HDTV720p, false },
new object[] { "Dexter - S01E01 - Title [HDTV-1080p]", Quality.HDTV1080p, false },
new object[] { "POI S02E11 1080i HDTV DD5.1 MPEG2-TrollHD", Quality.RAWHD, false },
new object[] { "How I Met Your Mother S01E18 Nothing Good Happens After 2 A.M. 720p HDTV DD5.1 MPEG2-TrollHD", Quality.RAWHD, false }
};
public static object[] SelfQualityParserCases =
{
new object[] { QualityTypes.SDTV },
new object[] { QualityTypes.DVD },
new object[] { QualityTypes.WEBDL480p },
new object[] { QualityTypes.HDTV720p },
new object[] { QualityTypes.WEBDL720p },
new object[] { QualityTypes.WEBDL1080p },
new object[] { QualityTypes.Bluray720p },
new object[] { QualityTypes.Bluray1080p }
new object[] { Quality.SDTV },
new object[] { Quality.DVD },
new object[] { Quality.WEBDL480p },
new object[] { Quality.HDTV720p },
new object[] { Quality.WEBDL720p },
new object[] { Quality.WEBDL1080p },
new object[] { Quality.Bluray720p },
new object[] { Quality.Bluray1080p }
};
[Test, TestCaseSource("QualityParserCases")]
public void quality_parse(string postTitle, QualityTypes quality, bool proper)
public void quality_parse(string postTitle, Quality quality, bool proper)
{
var result = Parser.ParseQuality(postTitle);
result.Quality.Should().Be(quality);
@ -102,7 +102,7 @@ public void quality_parse(string postTitle, QualityTypes quality, bool proper)
}
[Test, TestCaseSource("SelfQualityParserCases")]
public void parsing_our_own_quality_enum(QualityTypes quality)
public void parsing_our_own_quality_enum(Quality quality)
{
var fileName = String.Format("My series S01E01 [{0}]", quality);
var result = Parser.ParseQuality(fileName);

View File

@ -11,7 +11,6 @@
using NzbDrone.Core.Model.Notification;
using NzbDrone.Core.Providers;
using NzbDrone.Core.Repository;
using NzbDrone.Core.Repository.Quality;
using NzbDrone.Core.Test.Framework;
using NzbDrone.Test.Common.AutoMoq;
using NzbDrone.Test.Common;

View File

@ -8,12 +8,12 @@
using Moq;
using NUnit.Framework;
using NzbDrone.Common;
using NzbDrone.Core.Qualities;
using NzbDrone.Core.Tv;
using NzbDrone.Core.Model;
using NzbDrone.Core.Providers;
using NzbDrone.Core.Providers.Core;
using NzbDrone.Core.Repository;
using NzbDrone.Core.Repository.Quality;
using NzbDrone.Core.Test.Framework;
using NzbDrone.Test.Common;
using NzbDrone.Test.Common.AutoMoq;
@ -106,7 +106,7 @@ public void should_move_file_if_a_conflict_is_found()
Mocker.GetMock<IEpisodeService>().Setup(s => s.GetEpisodesByFileId(episodeFile.EpisodeFileId))
.Returns(episode);
Mocker.GetMock<MediaFileProvider>().Setup(s => s.GetNewFilename(It.IsAny<IList<Episode>>(), series, QualityTypes.Unknown, false, It.IsAny<EpisodeFile>()))
Mocker.GetMock<MediaFileProvider>().Setup(s => s.GetNewFilename(It.IsAny<IList<Episode>>(), series, Quality.Unknown, false, It.IsAny<EpisodeFile>()))
.Returns(newFilename);
Mocker.GetMock<MediaFileProvider>().Setup(s => s.CalculateFilePath(It.IsAny<Series>(), It.IsAny<int>(), It.IsAny<string>(), It.IsAny<string>()))

View File

@ -14,7 +14,6 @@
using NzbDrone.Core.Providers;
using NzbDrone.Core.Providers.Core;
using NzbDrone.Core.Repository;
using NzbDrone.Core.Repository.Quality;
using NzbDrone.Core.Test.Framework;
using NzbDrone.Test.Common;
using NzbDrone.Test.Common.AutoMoq;

View File

@ -12,7 +12,6 @@
using NzbDrone.Core.Providers;
using NzbDrone.Core.Providers.Core;
using NzbDrone.Core.Repository;
using NzbDrone.Core.Repository.Quality;
using NzbDrone.Core.Test.Framework;
using NzbDrone.Test.Common;
using NzbDrone.Test.Common.AutoMoq;

View File

@ -6,12 +6,12 @@
using Moq;
using NUnit.Framework;
using NzbDrone.Common;
using NzbDrone.Core.Qualities;
using NzbDrone.Core.Tv;
using NzbDrone.Core.Model;
using NzbDrone.Core.Providers;
using NzbDrone.Core.Providers.Core;
using NzbDrone.Core.Repository;
using NzbDrone.Core.Repository.Quality;
using NzbDrone.Core.Test.Framework;
using NzbDrone.Test.Common;
using NzbDrone.Test.Common.AutoMoq;
@ -23,9 +23,9 @@ public class ImportFileFixture : CoreTest
{
public static object[] ImportTestCases =
{
new object[] { QualityTypes.SDTV, false },
new object[] { QualityTypes.DVD, true },
new object[] { QualityTypes.HDTV720p, false }
new object[] { Quality.SDTV, false },
new object[] { Quality.DVD, true },
new object[] { Quality.HDTV720p, false }
};
private readonly long SIZE = 80.Megabytes();
@ -79,7 +79,7 @@ public void import_new_file_should_succeed()
}
[Test, TestCaseSource("ImportTestCases")]
public void import_new_file_with_better_same_quality_should_succeed(QualityTypes currentFileQuality, bool currentFileProper)
public void import_new_file_with_better_same_quality_should_succeed(Quality currentFileQuality, bool currentFileProper)
{
const string newFile = @"WEEDS.S03E01.DUAL.1080p.HELLYWOOD.mkv";
@ -87,7 +87,7 @@ public void import_new_file_with_better_same_quality_should_succeed(QualityTypes
var fakeSeries = Builder<Series>.CreateNew().Build();
var fakeEpisode = Builder<Episode>.CreateNew()
.With(e => e.EpisodeFile = Builder<EpisodeFile>.CreateNew()
.With(g => g.Quality = (QualityTypes)currentFileQuality)
.With(g => g.Quality = (Quality)currentFileQuality)
.And(g => g.Proper = currentFileProper).Build()
).Build();
@ -113,7 +113,7 @@ public void import_new_file_episode_has_same_or_better_quality_should_skip(strin
var fakeSeries = Builder<Series>.CreateNew().Build();
var fakeEpisode = Builder<Episode>.CreateNew()
.With(c => c.EpisodeFile = Builder<EpisodeFile>.CreateNew()
.With(e => e.Quality = QualityTypes.Bluray720p).Build()
.With(e => e.Quality = Quality.Bluray720p).Build()
)
.Build();
@ -214,7 +214,7 @@ public void import_new_file_episode_has_better_quality_than_existing(string file
var fakeSeries = Builder<Series>.CreateNew().Build();
var fakeEpisode = Builder<Episode>.CreateNew()
.With(c => c.EpisodeFile = Builder<EpisodeFile>.CreateNew()
.With(e => e.Quality = QualityTypes.SDTV).Build()
.With(e => e.Quality = Quality.SDTV).Build()
)
.Build();
@ -247,7 +247,7 @@ public void import_new_multi_part_file_episode_has_equal_or_better_quality_than_
var fakeEpisodes = Builder<Episode>.CreateListOfSize(2)
.All()
.With(e => e.EpisodeFile = Builder<EpisodeFile>.CreateNew()
.With(f => f.Quality = QualityTypes.SDTV)
.With(f => f.Quality = Quality.SDTV)
.Build())
.Build();
@ -278,7 +278,7 @@ public void skip_import_new_multi_part_file_episode_existing_has_better_quality(
var fakeEpisodes = Builder<Episode>.CreateListOfSize(2)
.All()
.With(e => e.EpisodeFile = Builder<EpisodeFile>.CreateNew()
.With(f => f.Quality = QualityTypes.Bluray720p)
.With(f => f.Quality = Quality.Bluray720p)
.Build())
.Build();
@ -310,7 +310,7 @@ public void import_new_multi_part_file_episode_replace_two_files()
var fakeEpisodeFiles = Builder<EpisodeFile>.CreateListOfSize(2)
.All()
.With(e => e.Quality = QualityTypes.SDTV)
.With(e => e.Quality = Quality.SDTV)
.Build();
var fakeEpisode1 = Builder<Episode>.CreateNew()

View File

@ -10,12 +10,12 @@
using NzbDrone.Common;
using NzbDrone.Core.Download;
using NzbDrone.Core.ExternalNotification;
using NzbDrone.Core.Qualities;
using NzbDrone.Core.Tv;
using NzbDrone.Core.Model;
using NzbDrone.Core.Providers;
using NzbDrone.Core.Providers.Core;
using NzbDrone.Core.Repository;
using NzbDrone.Core.Repository.Quality;
using NzbDrone.Core.Test.Framework;
using NzbDrone.Test.Common;
using NzbDrone.Test.Common.AutoMoq;
@ -57,7 +57,7 @@ public void should_not_move_file_if_source_and_destination_are_the_same_path()
.Returns(fakeEpisode);
Mocker.GetMock<MediaFileProvider>()
.Setup(e => e.GetNewFilename(fakeEpisode, fakeSeries, It.IsAny<QualityTypes>(), It.IsAny<bool>(), It.IsAny<EpisodeFile>()))
.Setup(e => e.GetNewFilename(fakeEpisode, fakeSeries, It.IsAny<Quality>(), It.IsAny<bool>(), It.IsAny<EpisodeFile>()))
.Returns(filename);
Mocker.GetMock<MediaFileProvider>()
@ -94,7 +94,7 @@ public void should_use_EpisodeFiles_quality()
var file = Builder<EpisodeFile>.CreateNew()
.With(f => f.SeriesId = fakeSeries.Id)
.With(f => f.Path = currentFilename)
.With(f => f.Quality = QualityTypes.WEBDL720p)
.With(f => f.Quality = Quality.WEBDL720p)
.With(f => f.Proper = false)
.Build();
@ -107,7 +107,7 @@ public void should_use_EpisodeFiles_quality()
.Returns(fakeEpisode);
Mocker.GetMock<MediaFileProvider>()
.Setup(e => e.GetNewFilename(fakeEpisode, fakeSeries, It.IsAny<QualityTypes>(), It.IsAny<bool>(), It.IsAny<EpisodeFile>()))
.Setup(e => e.GetNewFilename(fakeEpisode, fakeSeries, It.IsAny<Quality>(), It.IsAny<bool>(), It.IsAny<EpisodeFile>()))
.Returns(filename);
Mocker.GetMock<MediaFileProvider>()
@ -146,7 +146,7 @@ public void should_log_error_and_return_null_when_source_file_does_not_exists()
var file = Builder<EpisodeFile>.CreateNew()
.With(f => f.SeriesId = fakeSeries.Id)
.With(f => f.Path = currentFilename)
.With(f => f.Quality = QualityTypes.WEBDL720p)
.With(f => f.Quality = Quality.WEBDL720p)
.With(f => f.Proper = false)
.Build();
@ -159,7 +159,7 @@ public void should_log_error_and_return_null_when_source_file_does_not_exists()
.Returns(fakeEpisode);
Mocker.GetMock<MediaFileProvider>()
.Setup(e => e.GetNewFilename(fakeEpisode, fakeSeries, It.IsAny<QualityTypes>(), It.IsAny<bool>(), It.IsAny<EpisodeFile>()))
.Setup(e => e.GetNewFilename(fakeEpisode, fakeSeries, It.IsAny<Quality>(), It.IsAny<bool>(), It.IsAny<EpisodeFile>()))
.Returns(filename);
Mocker.GetMock<MediaFileProvider>()

View File

@ -9,13 +9,13 @@
using NUnit.Framework;
using NzbDrone.Common;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Qualities;
using NzbDrone.Core.Tv;
using NzbDrone.Core.Model;
using NzbDrone.Core.Model.Sabnzbd;
using NzbDrone.Core.Providers.Core;
using NzbDrone.Core.Providers.DownloadClients;
using NzbDrone.Core.Repository;
using NzbDrone.Core.Repository.Quality;
using NzbDrone.Core.Test.Framework;
using NzbDrone.Test.Common;
@ -130,7 +130,7 @@ public void is_in_queue_should_find_if_exact_episode_is_in_queue()
EpisodeTitle = "Title",
EpisodeNumbers = new List<int> { 5 },
SeasonNumber = 1,
Quality = new QualityModel { Quality = QualityTypes.SDTV, Proper = false },
Quality = new QualityModel { Quality = Quality.SDTV, Proper = false },
Series = new Series { Title = "30 Rock", CleanTitle = Parser.NormalizeTitle("30 Rock") },
};
@ -147,7 +147,7 @@ public void is_in_queue_should_find_if_exact_daily_episode_is_in_queue()
var parseResult = new EpisodeParseResult
{
Quality = new QualityModel { Quality = QualityTypes.Bluray720p, Proper = false },
Quality = new QualityModel { Quality = Quality.Bluray720p, Proper = false },
AirDate = new DateTime(2011, 12, 01),
Series = new Series { Title = "The Dailyshow", CleanTitle = Parser.NormalizeTitle("The Dailyshow"), SeriesType = SeriesType.Daily },
};
@ -166,7 +166,7 @@ public void is_in_queue_should_find_if_exact_full_season_release_is_in_queue()
var parseResult = new EpisodeParseResult
{
Quality = new QualityModel { Quality = QualityTypes.Bluray720p, Proper = false },
Quality = new QualityModel { Quality = Quality.Bluray720p, Proper = false },
FullSeason = true,
SeasonNumber = 5,
Series = new Series { Title = "My Name is earl", CleanTitle = Parser.NormalizeTitle("My Name is earl") },
@ -179,17 +179,17 @@ public void is_in_queue_should_find_if_exact_full_season_release_is_in_queue()
public static object[] DifferentEpisodeCases =
{
new object[] { 2, new[] { 5 }, "30 Rock", QualityTypes.Bluray1080p, true }, //Same Series, Different Season, Episode
new object[] { 1, new[] { 6 }, "30 Rock", QualityTypes.Bluray1080p, true }, //Same series, different episodes
new object[] { 1, new[] { 6, 7, 8 }, "30 Rock", QualityTypes.Bluray1080p, true }, //Same series, different episodes
new object[] { 1, new[] { 6 }, "Some other show", QualityTypes.Bluray1080p, true }, //Different series, same season, episode
new object[] { 1, new[] { 5 }, "Rock", QualityTypes.Bluray1080p, true }, //Similar series, same season, episodes
new object[] { 1, new[] { 5 }, "30 Rock", QualityTypes.Bluray720p, false }, //Same series, higher quality
new object[] { 1, new[] { 5 }, "30 Rock", QualityTypes.HDTV720p, true } //Same series, higher quality
new object[] { 2, new[] { 5 }, "30 Rock", Quality.Bluray1080p, true }, //Same Series, Different Season, Episode
new object[] { 1, new[] { 6 }, "30 Rock", Quality.Bluray1080p, true }, //Same series, different episodes
new object[] { 1, new[] { 6, 7, 8 }, "30 Rock", Quality.Bluray1080p, true }, //Same series, different episodes
new object[] { 1, new[] { 6 }, "Some other show", Quality.Bluray1080p, true }, //Different series, same season, episode
new object[] { 1, new[] { 5 }, "Rock", Quality.Bluray1080p, true }, //Similar series, same season, episodes
new object[] { 1, new[] { 5 }, "30 Rock", Quality.Bluray720p, false }, //Same series, higher quality
new object[] { 1, new[] { 5 }, "30 Rock", Quality.HDTV720p, true } //Same series, higher quality
};
[Test, TestCaseSource("DifferentEpisodeCases")]
public void IsInQueue_should_not_find_diffrent_episode_queue(int season, int[] episodes, string title, QualityTypes qualityType, bool proper)
public void IsInQueue_should_not_find_diffrent_episode_queue(int season, int[] episodes, string title, Quality qualityType, bool proper)
{
WithFullQueue();
@ -209,16 +209,16 @@ public void IsInQueue_should_not_find_diffrent_episode_queue(int season, int[] e
public static object[] LowerQualityCases =
{
new object[] { 1, new[] { 5 }, "30 Rock", QualityTypes.SDTV, false }, //Same Series, lower quality
new object[] { 1, new[] { 5 }, "30 rocK", QualityTypes.SDTV, false }, //Same Series, different casing
new object[] { 1, new[] { 5 }, "30 RocK", QualityTypes.HDTV720p, false }, //Same Series, same quality
new object[] { 1, new[] { 5, 6 }, "30 RocK", QualityTypes.HDTV720p, false }, //Same Series, same quality, one different episode
new object[] { 1, new[] { 5, 6 }, "30 RocK", QualityTypes.HDTV720p, false }, //Same Series, same quality, one different episode
new object[] { 4, new[] { 8 }, "Parks and Recreation", QualityTypes.WEBDL720p, false }, //Same Series, same quality
new object[] { 1, new[] { 5 }, "30 Rock", Quality.SDTV, false }, //Same Series, lower quality
new object[] { 1, new[] { 5 }, "30 rocK", Quality.SDTV, false }, //Same Series, different casing
new object[] { 1, new[] { 5 }, "30 RocK", Quality.HDTV720p, false }, //Same Series, same quality
new object[] { 1, new[] { 5, 6 }, "30 RocK", Quality.HDTV720p, false }, //Same Series, same quality, one different episode
new object[] { 1, new[] { 5, 6 }, "30 RocK", Quality.HDTV720p, false }, //Same Series, same quality, one different episode
new object[] { 4, new[] { 8 }, "Parks and Recreation", Quality.WEBDL720p, false }, //Same Series, same quality
};
[Test, TestCaseSource("LowerQualityCases")]
public void IsInQueue_should_find_same_or_lower_quality_episode_queue(int season, int[] episodes, string title, QualityTypes qualityType, bool proper)
public void IsInQueue_should_find_same_or_lower_quality_episode_queue(int season, int[] episodes, string title, Quality qualityType, bool proper)
{
WithFullQueue();
@ -238,14 +238,14 @@ public void IsInQueue_should_find_same_or_lower_quality_episode_queue(int season
public static object[] DuplicateItemsCases =
{
new object[] { 5, new[] { 13 }, "The Big Bang Theory", QualityTypes.SDTV, false }, //Same Series, lower quality
new object[] { 5, new[] { 13 }, "The Big Bang Theory", QualityTypes.HDTV720p, false }, //Same Series, same quality
new object[] { 5, new[] { 13 }, "The Big Bang Theory", QualityTypes.HDTV720p, true }, //Same Series, same quality
new object[] { 5, new[] { 13, 14 }, "The Big Bang Theory", QualityTypes.HDTV720p, false } //Same Series, same quality, one diffrent episode
new object[] { 5, new[] { 13 }, "The Big Bang Theory", Quality.SDTV, false }, //Same Series, lower quality
new object[] { 5, new[] { 13 }, "The Big Bang Theory", Quality.HDTV720p, false }, //Same Series, same quality
new object[] { 5, new[] { 13 }, "The Big Bang Theory", Quality.HDTV720p, true }, //Same Series, same quality
new object[] { 5, new[] { 13, 14 }, "The Big Bang Theory", Quality.HDTV720p, false } //Same Series, same quality, one diffrent episode
};
[Test, TestCaseSource("DuplicateItemsCases")]
public void IsInQueue_should_find_items_marked_as_duplicate(int season, int[] episodes, string title, QualityTypes qualityType, bool proper)
public void IsInQueue_should_find_items_marked_as_duplicate(int season, int[] episodes, string title, Quality qualityType, bool proper)
{
WithFullQueue();
@ -265,14 +265,14 @@ public void IsInQueue_should_find_items_marked_as_duplicate(int season, int[] ep
public static object[] DoubleEpisodeCases =
{
new object[] { 3, new[] { 14, 15 }, "My Name Is Earl", QualityTypes.Bluray720p, false },
new object[] { 3, new[] { 15 }, "My Name Is Earl", QualityTypes.DVD, false },
new object[] { 3, new[] { 14 }, "My Name Is Earl", QualityTypes.HDTV720p, false },
new object[] { 3, new[] { 15, 16 }, "My Name Is Earl", QualityTypes.SDTV, false }
new object[] { 3, new[] { 14, 15 }, "My Name Is Earl", Quality.Bluray720p, false },
new object[] { 3, new[] { 15 }, "My Name Is Earl", Quality.DVD, false },
new object[] { 3, new[] { 14 }, "My Name Is Earl", Quality.HDTV720p, false },
new object[] { 3, new[] { 15, 16 }, "My Name Is Earl", Quality.SDTV, false }
};
[Test, TestCaseSource("DoubleEpisodeCases")]
public void IsInQueue_should_find_double_episodes_(int season, int[] episodes, string title, QualityTypes qualityType, bool proper)
public void IsInQueue_should_find_double_episodes_(int season, int[] episodes, string title, Quality qualityType, bool proper)
{
WithFullQueue();
@ -300,7 +300,7 @@ public void IsInQueue_should_return_false_if_queue_is_empty()
EpisodeTitle = "Title",
EpisodeNumbers = new List<int> { 1 },
SeasonNumber = 2,
Quality = new QualityModel { Quality = QualityTypes.Bluray1080p, Proper = true },
Quality = new QualityModel { Quality = Quality.Bluray1080p, Proper = true },
Series = new Series { Title = "Test", CleanTitle = Parser.NormalizeTitle("Test") },
};

View File

@ -16,7 +16,6 @@
using NzbDrone.Core.Providers.Core;
using NzbDrone.Core.Providers.DownloadClients;
using NzbDrone.Core.Repository;
using NzbDrone.Core.Repository.Quality;
using NzbDrone.Core.Test.Framework;
using NzbDrone.Test.Common;

View File

@ -7,10 +7,10 @@
using NUnit.Framework;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Download;
using NzbDrone.Core.Qualities;
using NzbDrone.Core.Tv;
using NzbDrone.Core.Model;
using NzbDrone.Core.Providers.DownloadClients;
using NzbDrone.Core.Repository.Quality;
using NzbDrone.Core.Test.Framework;
// ReSharper disable InconsistentNaming
@ -41,7 +41,7 @@ private EpisodeParseResult SetupParseResult()
.Setup(c => c.GetEpisodesByParseResult(It.IsAny<EpisodeParseResult>())).Returns(episodes);
return Builder<EpisodeParseResult>.CreateNew()
.With(c => c.Quality = new QualityModel(QualityTypes.DVD, false))
.With(c => c.Quality = new QualityModel(Quality.DVD, false))
.With(c => c.Series = Builder<Series>.CreateNew().Build())
.With(c => c.EpisodeNumbers = new List<int> { 2 })
.With(c => c.Episodes = episodes)

View File

@ -8,7 +8,6 @@
using NzbDrone.Core.Model;
using NzbDrone.Core.Providers;
using NzbDrone.Core.Repository;
using NzbDrone.Core.Repository.Quality;
using NzbDrone.Core.Test.Framework;
using NzbDrone.Test.Common.AutoMoq;

View File

@ -9,12 +9,12 @@
using NUnit.Framework;
using NzbDrone.Common;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Qualities;
using NzbDrone.Core.Tv;
using NzbDrone.Core.Model;
using NzbDrone.Core.Providers;
using NzbDrone.Core.Providers.Core;
using NzbDrone.Core.Repository;
using NzbDrone.Core.Repository.Quality;
using NzbDrone.Core.Test.Framework;
using NzbDrone.Test.Common.AutoMoq;
@ -29,12 +29,12 @@ public void get_series_files()
{
var firstSeriesFiles = Builder<EpisodeFile>.CreateListOfSize(10)
.All()
.With(c => c.Quality = QualityTypes.SDTV)
.With(c => c.Quality = Quality.SDTV)
.With(s => s.SeriesId = 12).Build();
var secondSeriesFiles = Builder<EpisodeFile>.CreateListOfSize(10)
.All()
.With(c => c.Quality = QualityTypes.SDTV)
.With(c => c.Quality = Quality.SDTV)
.With(s => s.SeriesId = 20).Build();
@ -56,14 +56,14 @@ public void get_season_files()
{
var firstSeriesFiles = Builder<EpisodeFile>.CreateListOfSize(10)
.All()
.With(c => c.Quality = QualityTypes.SDTV)
.With(c => c.Quality = Quality.SDTV)
.With(s => s.SeriesId = 12)
.With(s => s.SeasonNumber = 1)
.Build();
var secondSeriesFiles = Builder<EpisodeFile>.CreateListOfSize(10)
.All()
.With(c => c.Quality = QualityTypes.SDTV)
.With(c => c.Quality = Quality.SDTV)
.With(s => s.SeriesId = 12)
.With(s => s.SeasonNumber = 2)
.Build();
@ -150,7 +150,7 @@ public void DeleteEpisodeFile()
var episodeFiles = Builder<EpisodeFile>
.CreateListOfSize(10)
.All()
.With(c => c.Quality = QualityTypes.SDTV)
.With(c => c.Quality = Quality.SDTV)
.Build();
@ -187,7 +187,7 @@ public void GetFileByPath_should_return_EpisodeFile_if_file_exists_in_database()
//Setup
WithRealDb();
var episodeFile = Builder<EpisodeFile>.CreateNew()
.With(c => c.Quality = QualityTypes.SDTV)
.With(c => c.Quality = Quality.SDTV)
.With(f => f.Path = path.NormalizePath())
.Build();

View File

@ -6,12 +6,12 @@
using FluentAssertions;
using NUnit.Framework;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Qualities;
using NzbDrone.Core.Tv;
using NzbDrone.Core.Model;
using NzbDrone.Core.Providers;
using NzbDrone.Core.Providers.Core;
using NzbDrone.Core.Repository;
using NzbDrone.Core.Repository.Quality;
using NzbDrone.Core.Test.Framework;
namespace NzbDrone.Core.Test.ProviderTests.MediaFileProviderTests
@ -121,7 +121,7 @@ public void DeleteOrphanedEpisodeFiles()
var episodeFiles = Builder<EpisodeFile>
.CreateListOfSize(10)
.All()
.With(e => e.Quality = QualityTypes.DVD)
.With(e => e.Quality = Quality.DVD)
.Build();
var episodes = Builder<Episode>.CreateListOfSize(5).Build();

View File

@ -8,11 +8,11 @@
using FluentAssertions;
using NUnit.Framework;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Qualities;
using NzbDrone.Core.Tv;
using NzbDrone.Core.Providers;
using NzbDrone.Core.Providers.Core;
using NzbDrone.Core.Repository;
using NzbDrone.Core.Repository.Quality;
using NzbDrone.Core.Test.Framework;
using NzbDrone.Test.Common.AutoMoq;
@ -54,7 +54,7 @@ public void GetNewFilename_Series_Episode_Quality_S01E05_Dash()
.Build();
//Act
string result = Mocker.Resolve<MediaFileProvider>().GetNewFilename(new List<Episode> { episode }, _series, QualityTypes.HDTV720p, false, new EpisodeFile());
string result = Mocker.Resolve<MediaFileProvider>().GetNewFilename(new List<Episode> { episode }, _series, Quality.HDTV720p, false, new EpisodeFile());
//Assert
Assert.AreEqual("South Park - S15E06 - City Sushi [HDTV-720p]", result);
@ -81,7 +81,7 @@ public void GetNewFilename_Episode_Quality_1x05_Dash()
.Build();
//Act
string result = Mocker.Resolve<MediaFileProvider>().GetNewFilename(new List<Episode> { episode }, _series, QualityTypes.HDTV720p, false, new EpisodeFile());
string result = Mocker.Resolve<MediaFileProvider>().GetNewFilename(new List<Episode> { episode }, _series, Quality.HDTV720p, false, new EpisodeFile());
//Assert
Assert.AreEqual("15x06 - City Sushi [HDTV-720p]", result);
@ -108,7 +108,7 @@ public void GetNewFilename_Series_Quality_01x05_Space()
.Build();
//Act
string result = Mocker.Resolve<MediaFileProvider>().GetNewFilename(new List<Episode> { episode }, _series, QualityTypes.HDTV720p, false, new EpisodeFile());
string result = Mocker.Resolve<MediaFileProvider>().GetNewFilename(new List<Episode> { episode }, _series, Quality.HDTV720p, false, new EpisodeFile());
//Assert
Assert.AreEqual("South Park 05x06 [HDTV-720p]", result);
@ -136,7 +136,7 @@ public void GetNewFilename_Series_s01e05_Space()
.Build();
//Act
string result = Mocker.Resolve<MediaFileProvider>().GetNewFilename(new List<Episode> { episode }, _series, QualityTypes.HDTV720p, false, new EpisodeFile());
string result = Mocker.Resolve<MediaFileProvider>().GetNewFilename(new List<Episode> { episode }, _series, Quality.HDTV720p, false, new EpisodeFile());
//Assert
Assert.AreEqual("South Park s05e06", result);
@ -163,7 +163,7 @@ public void GetNewFilename_Series_Episode_s01e05_Periods()
.Build();
//Act
string result = Mocker.Resolve<MediaFileProvider>().GetNewFilename(new List<Episode> { episode }, _series, QualityTypes.HDTV720p, false, new EpisodeFile());
string result = Mocker.Resolve<MediaFileProvider>().GetNewFilename(new List<Episode> { episode }, _series, Quality.HDTV720p, false, new EpisodeFile());
//Assert
Assert.AreEqual("South.Park.s05e06.City.Sushi", result);
@ -190,7 +190,7 @@ public void GetNewFilename_Series_Episode_s01e05_Dash_Periods_Quality()
.Build();
//Act
string result = Mocker.Resolve<MediaFileProvider>().GetNewFilename(new List<Episode> { episode }, _series, QualityTypes.HDTV720p, false, new EpisodeFile());
string result = Mocker.Resolve<MediaFileProvider>().GetNewFilename(new List<Episode> { episode }, _series, Quality.HDTV720p, false, new EpisodeFile());
//Assert
Assert.AreEqual("South.Park.-.s05e06.-.City.Sushi.[HDTV-720p]", result);
@ -218,7 +218,7 @@ public void GetNewFilename_S01E05_Dash()
.Build();
//Act
string result = Mocker.Resolve<MediaFileProvider>().GetNewFilename(new List<Episode> { episode }, _series, QualityTypes.HDTV720p, false, new EpisodeFile());
string result = Mocker.Resolve<MediaFileProvider>().GetNewFilename(new List<Episode> { episode }, _series, Quality.HDTV720p, false, new EpisodeFile());
//Assert
Assert.AreEqual("S15E06", result);
@ -252,7 +252,7 @@ public void GetNewFilename_multi_Series_Episode_Quality_S01E05_Scene_Dash()
.Build();
//Act
string result = Mocker.Resolve<MediaFileProvider>().GetNewFilename(new List<Episode> { episodeOne, episodeTwo }, new Series { Title = "The Mentalist" }, QualityTypes.HDTV720p, false, new EpisodeFile());
string result = Mocker.Resolve<MediaFileProvider>().GetNewFilename(new List<Episode> { episodeOne, episodeTwo }, new Series { Title = "The Mentalist" }, Quality.HDTV720p, false, new EpisodeFile());
//Assert
Assert.AreEqual("The Mentalist - S03E23-E24 - Strawberries and Cream [HDTV-720p]", result);
@ -286,7 +286,7 @@ public void GetNewFilename_multi_Episode_Quality_1x05_Repeat_Dash()
.Build();
//Act
string result = Mocker.Resolve<MediaFileProvider>().GetNewFilename(new List<Episode> { episodeOne, episodeTwo }, new Series { Title = "The Mentalist" }, QualityTypes.HDTV720p, false, new EpisodeFile());
string result = Mocker.Resolve<MediaFileProvider>().GetNewFilename(new List<Episode> { episodeOne, episodeTwo }, new Series { Title = "The Mentalist" }, Quality.HDTV720p, false, new EpisodeFile());
//Assert
Assert.AreEqual("3x23x24 - Strawberries and Cream [HDTV-720p]", result);
@ -320,7 +320,7 @@ public void GetNewFilename_multi_Episode_Quality_01x05_Repeat_Space()
.Build();
//Act
string result = Mocker.Resolve<MediaFileProvider>().GetNewFilename(new List<Episode> { episodeOne, episodeTwo }, new Series { Title = "The Mentalist" }, QualityTypes.HDTV720p, false, new EpisodeFile());
string result = Mocker.Resolve<MediaFileProvider>().GetNewFilename(new List<Episode> { episodeOne, episodeTwo }, new Series { Title = "The Mentalist" }, Quality.HDTV720p, false, new EpisodeFile());
//Assert
Assert.AreEqual("3x23x24 Strawberries and Cream [HDTV-720p]", result);
@ -354,7 +354,7 @@ public void GetNewFilename_multi_Series_Episode_s01e05_Duplicate_Period()
.Build();
//Act
string result = Mocker.Resolve<MediaFileProvider>().GetNewFilename(new List<Episode> { episodeOne, episodeTwo }, new Series { Title = "The Mentalist" }, QualityTypes.HDTV720p, false, new EpisodeFile());
string result = Mocker.Resolve<MediaFileProvider>().GetNewFilename(new List<Episode> { episodeOne, episodeTwo }, new Series { Title = "The Mentalist" }, Quality.HDTV720p, false, new EpisodeFile());
//Assert
Assert.AreEqual("The.Mentalist.s03e23.s03e24.Strawberries.and.Cream", result);
@ -388,7 +388,7 @@ public void GetNewFilename_multi_Series_S01E05_Extend_Dash_Period()
.Build();
//Act
string result = Mocker.Resolve<MediaFileProvider>().GetNewFilename(new List<Episode> { episodeOne, episodeTwo }, new Series { Title = "The Mentalist" }, QualityTypes.HDTV720p, false, new EpisodeFile());
string result = Mocker.Resolve<MediaFileProvider>().GetNewFilename(new List<Episode> { episodeOne, episodeTwo }, new Series { Title = "The Mentalist" }, Quality.HDTV720p, false, new EpisodeFile());
//Assert
Assert.AreEqual("The.Mentalist.-.S03E23-24", result);
@ -422,7 +422,7 @@ public void GetNewFilename_multi_1x05_Repeat_Dash_Period()
.Build();
//Act
string result = Mocker.Resolve<MediaFileProvider>().GetNewFilename(new List<Episode> { episodeOne, episodeTwo }, new Series { Title = "The Mentalist" }, QualityTypes.HDTV720p, false, new EpisodeFile());
string result = Mocker.Resolve<MediaFileProvider>().GetNewFilename(new List<Episode> { episodeOne, episodeTwo }, new Series { Title = "The Mentalist" }, Quality.HDTV720p, false, new EpisodeFile());
//Assert
Assert.AreEqual("3x23x24", result);
@ -447,7 +447,7 @@ public void GetNewFilename_should_append_proper_when_proper_and_append_quality_i
.Build();
//Act
string result = Mocker.Resolve<MediaFileProvider>().GetNewFilename(new List<Episode> { episode }, _series, QualityTypes.HDTV720p, true, new EpisodeFile());
string result = Mocker.Resolve<MediaFileProvider>().GetNewFilename(new List<Episode> { episode }, _series, Quality.HDTV720p, true, new EpisodeFile());
//Assert
result.Should().Be("South Park - S15E06 - City Sushi [HDTV-720p] [Proper]");
@ -472,7 +472,7 @@ public void GetNewFilename_should_not_append_proper_when_not_proper_and_append_q
.Build();
//Act
string result = Mocker.Resolve<MediaFileProvider>().GetNewFilename(new List<Episode> { episode }, _series, QualityTypes.HDTV720p, false, new EpisodeFile());
string result = Mocker.Resolve<MediaFileProvider>().GetNewFilename(new List<Episode> { episode }, _series, Quality.HDTV720p, false, new EpisodeFile());
//Assert
result.Should().Be("South Park - S15E06 - City Sushi [HDTV-720p]");
@ -497,7 +497,7 @@ public void GetNewFilename_should_not_append_proper_when_proper_and_append_quali
.Build();
//Act
string result = Mocker.Resolve<MediaFileProvider>().GetNewFilename(new List<Episode> { episode }, _series, QualityTypes.HDTV720p, true, new EpisodeFile());
string result = Mocker.Resolve<MediaFileProvider>().GetNewFilename(new List<Episode> { episode }, _series, Quality.HDTV720p, true, new EpisodeFile());
//Assert
result.Should().Be("South Park - S15E06 - City Sushi");
@ -529,7 +529,7 @@ public void GetNewFilename_should_order_multiple_episode_files_in_numerical_orde
.Build();
//Act
string result = Mocker.Resolve<MediaFileProvider>().GetNewFilename(new List<Episode> { episode2, episode }, new Series { Title = "30 Rock" }, QualityTypes.HDTV720p, false, new EpisodeFile());
string result = Mocker.Resolve<MediaFileProvider>().GetNewFilename(new List<Episode> { episode2, episode }, new Series { Title = "30 Rock" }, Quality.HDTV720p, false, new EpisodeFile());
//Assert
result.Should().Be("30 Rock - S06E06-E07 - Hey, Baby, What's Wrong!");
@ -556,7 +556,7 @@ public void GetNewFilename_Series_Episode_Quality_S01E05_Period()
.Build();
//Act
string result = Mocker.Resolve<MediaFileProvider>().GetNewFilename(new List<Episode> { episode }, _series, QualityTypes.HDTV720p, false, new EpisodeFile());
string result = Mocker.Resolve<MediaFileProvider>().GetNewFilename(new List<Episode> { episode }, _series, Quality.HDTV720p, false, new EpisodeFile());
//Assert
Assert.AreEqual("South Park.S15E06.City Sushi [HDTV-720p]", result);
@ -583,7 +583,7 @@ public void GetNewFilename_Episode_Quality_1x05_Period()
.Build();
//Act
string result = Mocker.Resolve<MediaFileProvider>().GetNewFilename(new List<Episode> { episode }, _series, QualityTypes.HDTV720p, false, new EpisodeFile());
string result = Mocker.Resolve<MediaFileProvider>().GetNewFilename(new List<Episode> { episode }, _series, Quality.HDTV720p, false, new EpisodeFile());
//Assert
Assert.AreEqual("15x06.City Sushi [HDTV-720p]", result);
@ -614,7 +614,7 @@ public void GetNewFilename_UseSceneName_when_sceneName_isNull()
.Build();
//Act
string result = Mocker.Resolve<MediaFileProvider>().GetNewFilename(new List<Episode> { episode }, _series, QualityTypes.HDTV720p, false, episodeFile);
string result = Mocker.Resolve<MediaFileProvider>().GetNewFilename(new List<Episode> { episode }, _series, Quality.HDTV720p, false, episodeFile);
//Assert
result.Should().Be(Path.GetFileNameWithoutExtension(episodeFile.Path));
@ -645,7 +645,7 @@ public void GetNewFilename_UseSceneName_when_sceneName_isNotNull()
.Build();
//Act
string result = Mocker.Resolve<MediaFileProvider>().GetNewFilename(new List<Episode> { episode }, _series, QualityTypes.HDTV720p, false, episodeFile);
string result = Mocker.Resolve<MediaFileProvider>().GetNewFilename(new List<Episode> { episode }, _series, Quality.HDTV720p, false, episodeFile);
//Assert
result.Should().Be(episodeFile.SceneName);
@ -677,7 +677,7 @@ public void should_only_have_one_episodeTitle_when_episode_titles_are_the_same()
.Build();
//Act
string result = Mocker.Resolve<MediaFileProvider>().GetNewFilename(new List<Episode> { episode2, episode }, new Series { Title = "30 Rock" }, QualityTypes.HDTV720p, false, new EpisodeFile());
string result = Mocker.Resolve<MediaFileProvider>().GetNewFilename(new List<Episode> { episode2, episode }, new Series { Title = "30 Rock" }, Quality.HDTV720p, false, new EpisodeFile());
//Assert
result.Should().Be("30 Rock - S06E06-E07 - Hey, Baby, What's Wrong!");
@ -709,7 +709,7 @@ public void should_have_two_episodeTitles_when_episode_titles_are_not_the_same()
.Build();
//Act
string result = Mocker.Resolve<MediaFileProvider>().GetNewFilename(new List<Episode> { episode2, episode }, new Series { Title = "30 Rock" }, QualityTypes.HDTV720p, false, new EpisodeFile());
string result = Mocker.Resolve<MediaFileProvider>().GetNewFilename(new List<Episode> { episode2, episode }, new Series { Title = "30 Rock" }, Quality.HDTV720p, false, new EpisodeFile());
//Assert
result.Should().Be("30 Rock - S06E06-E07 - Hello + World");
@ -747,7 +747,7 @@ public void should_have_two_episodeTitles_when_distinct_count_is_two()
.Build();
//Act
string result = Mocker.Resolve<MediaFileProvider>().GetNewFilename(new List<Episode> { episode, episode2, episode3 }, new Series { Title = "30 Rock" }, QualityTypes.HDTV720p, false, new EpisodeFile());
string result = Mocker.Resolve<MediaFileProvider>().GetNewFilename(new List<Episode> { episode, episode2, episode3 }, new Series { Title = "30 Rock" }, Quality.HDTV720p, false, new EpisodeFile());
//Assert
result.Should().Be("30 Rock - S06E06-E07-E08 - Hello + World");
@ -778,7 +778,7 @@ public void should_use_airDate_if_series_isDaily()
.Build();
var result = Mocker.Resolve<MediaFileProvider>()
.GetNewFilename(episodes, series, QualityTypes.HDTV720p, false, new EpisodeFile());
.GetNewFilename(episodes, series, Quality.HDTV720p, false, new EpisodeFile());
result.Should().Be("The Daily Show with Jon Stewart - 2012-12-13 - Kristen Stewart [HDTV-720p]");
}
@ -807,7 +807,7 @@ public void should_use_airDate_if_series_isDaily_no_episode_title()
.Build();
var result = Mocker.Resolve<MediaFileProvider>()
.GetNewFilename(episodes, series, QualityTypes.HDTV720p, false, new EpisodeFile());
.GetNewFilename(episodes, series, Quality.HDTV720p, false, new EpisodeFile());
result.Should().Be("The Daily Show with Jon Stewart - 2012-12-13");
}
@ -836,7 +836,7 @@ public void should_set_airdate_to_unknown_if_not_available()
.Build();
var result = Mocker.Resolve<MediaFileProvider>()
.GetNewFilename(episodes, series, QualityTypes.HDTV720p, false, new EpisodeFile());
.GetNewFilename(episodes, series, Quality.HDTV720p, false, new EpisodeFile());
result.Should().Be("The Daily Show with Jon Stewart - Unknown - Kristen Stewart");
}
}

View File

@ -15,7 +15,6 @@
using NzbDrone.Core.Providers.Core;
using NzbDrone.Core.Providers.Metadata;
using NzbDrone.Core.Repository;
using NzbDrone.Core.Repository.Quality;
using NzbDrone.Core.Test.Framework;
using NzbDrone.Test.Common.AutoMoq;
using NzbDrone.Test.Common;

View File

@ -14,7 +14,6 @@
using NzbDrone.Core.Providers.Core;
using NzbDrone.Core.Providers.Metadata;
using NzbDrone.Core.Repository;
using NzbDrone.Core.Repository.Quality;
using NzbDrone.Core.Test.Framework;
using NzbDrone.Test.Common.AutoMoq;
using NzbDrone.Test.Common;

View File

@ -4,10 +4,10 @@
using FluentAssertions;
using Moq;
using NUnit.Framework;
using NzbDrone.Core.Qualities;
using NzbDrone.Core.Tv;
using NzbDrone.Core.Providers;
using NzbDrone.Core.Repository;
using NzbDrone.Core.Repository.Quality;
using NzbDrone.Core.Test.Framework;
using NzbDrone.Test.Common.AutoMoq;
@ -48,11 +48,11 @@ public void no_misnamed_files()
.Setup(c => c.EpisodesWithFiles()).Returns(episodes);
Mocker.GetMock<MediaFileProvider>()
.Setup(c => c.GetNewFilename(new List<Episode> { episodes[0] }, It.IsAny<Series>(), It.IsAny<QualityTypes>(), It.IsAny<bool>(), episodeFiles[0]))
.Setup(c => c.GetNewFilename(new List<Episode> { episodes[0] }, It.IsAny<Series>(), It.IsAny<Quality>(), It.IsAny<bool>(), episodeFiles[0]))
.Returns("Title1");
Mocker.GetMock<MediaFileProvider>()
.Setup(c => c.GetNewFilename(new List<Episode> { episodes[1] }, It.IsAny<Series>(), It.IsAny<QualityTypes>(), It.IsAny<bool>(), episodeFiles[1]))
.Setup(c => c.GetNewFilename(new List<Episode> { episodes[1] }, It.IsAny<Series>(), It.IsAny<Quality>(), It.IsAny<bool>(), episodeFiles[1]))
.Returns("Title2");
//Act
@ -95,11 +95,11 @@ public void all_misnamed_files()
.Setup(c => c.EpisodesWithFiles()).Returns(episodes);
Mocker.GetMock<MediaFileProvider>()
.Setup(c => c.GetNewFilename(new List<Episode> { episodes[0] }, It.IsAny<Series>(), It.IsAny<QualityTypes>(), It.IsAny<bool>(), episodeFiles[0]))
.Setup(c => c.GetNewFilename(new List<Episode> { episodes[0] }, It.IsAny<Series>(), It.IsAny<Quality>(), It.IsAny<bool>(), episodeFiles[0]))
.Returns("New Title 1");
Mocker.GetMock<MediaFileProvider>()
.Setup(c => c.GetNewFilename(new List<Episode> { episodes[1] }, It.IsAny<Series>(), It.IsAny<QualityTypes>(), It.IsAny<bool>(), episodeFiles[1]))
.Setup(c => c.GetNewFilename(new List<Episode> { episodes[1] }, It.IsAny<Series>(), It.IsAny<Quality>(), It.IsAny<bool>(), episodeFiles[1]))
.Returns("New Title 2");
//Act
@ -142,11 +142,11 @@ public void one_misnamed_file()
.Setup(c => c.EpisodesWithFiles()).Returns(episodes);
Mocker.GetMock<MediaFileProvider>()
.Setup(c => c.GetNewFilename(new List<Episode> { episodes[0] }, It.IsAny<Series>(), It.IsAny<QualityTypes>(), It.IsAny<bool>(), episodeFiles[0]))
.Setup(c => c.GetNewFilename(new List<Episode> { episodes[0] }, It.IsAny<Series>(), It.IsAny<Quality>(), It.IsAny<bool>(), episodeFiles[0]))
.Returns("New Title 1");
Mocker.GetMock<MediaFileProvider>()
.Setup(c => c.GetNewFilename(new List<Episode> { episodes[1] }, It.IsAny<Series>(), It.IsAny<QualityTypes>(), It.IsAny<bool>(), episodeFiles[1]))
.Setup(c => c.GetNewFilename(new List<Episode> { episodes[1] }, It.IsAny<Series>(), It.IsAny<Quality>(), It.IsAny<bool>(), episodeFiles[1]))
.Returns("Title2");
//Act
@ -191,11 +191,11 @@ public void misnamed_multi_episode_file()
.Setup(c => c.EpisodesWithFiles()).Returns(episodes);
Mocker.GetMock<MediaFileProvider>()
.Setup(c => c.GetNewFilename(new List<Episode> { episodes[0], episodes[1] }, It.IsAny<Series>(), It.IsAny<QualityTypes>(), It.IsAny<bool>(), episodeFiles[0]))
.Setup(c => c.GetNewFilename(new List<Episode> { episodes[0], episodes[1] }, It.IsAny<Series>(), It.IsAny<Quality>(), It.IsAny<bool>(), episodeFiles[0]))
.Returns("New Title 1");
Mocker.GetMock<MediaFileProvider>()
.Setup(c => c.GetNewFilename(new List<Episode> { episodes[2] }, It.IsAny<Series>(), It.IsAny<QualityTypes>(), It.IsAny<bool>(), episodeFiles[1]))
.Setup(c => c.GetNewFilename(new List<Episode> { episodes[2] }, It.IsAny<Series>(), It.IsAny<Quality>(), It.IsAny<bool>(), episodeFiles[1]))
.Returns("Title2");
//Act
@ -240,11 +240,11 @@ public void no_misnamed_multi_episode_file()
.Setup(c => c.EpisodesWithFiles()).Returns(episodes);
Mocker.GetMock<MediaFileProvider>()
.Setup(c => c.GetNewFilename(new List<Episode> { episodes[0], episodes[1] }, It.IsAny<Series>(), It.IsAny<QualityTypes>(), It.IsAny<bool>(), episodeFiles[0]))
.Setup(c => c.GetNewFilename(new List<Episode> { episodes[0], episodes[1] }, It.IsAny<Series>(), It.IsAny<Quality>(), It.IsAny<bool>(), episodeFiles[0]))
.Returns("Title1");
Mocker.GetMock<MediaFileProvider>()
.Setup(c => c.GetNewFilename(new List<Episode> { episodes[2] }, It.IsAny<Series>(), It.IsAny<QualityTypes>(), It.IsAny<bool>(), episodeFiles[1]))
.Setup(c => c.GetNewFilename(new List<Episode> { episodes[2] }, It.IsAny<Series>(), It.IsAny<Quality>(), It.IsAny<bool>(), episodeFiles[1]))
.Returns("Title2");
//Act

View File

@ -7,7 +7,6 @@
using NzbDrone.Core.Model;
using NzbDrone.Core.Providers;
using NzbDrone.Core.Repository;
using NzbDrone.Core.Repository.Quality;
using NzbDrone.Core.Test.Framework;
using NzbDrone.Test.Common;
using NzbDrone.Test.Common.AutoMoq;

View File

@ -1,95 +0,0 @@
// ReSharper disable RedundantUsingDirective
using System.Collections.Generic;
using FizzWare.NBuilder;
using FluentAssertions;
using NUnit.Framework;
using NzbDrone.Core.Providers;
using NzbDrone.Core.Repository.Quality;
using NzbDrone.Core.Test.Framework;
using NzbDrone.Test.Common.AutoMoq;
namespace NzbDrone.Core.Test.ProviderTests
{
[TestFixture]
// ReSharper disable InconsistentNaming
public class QualityTypeProviderTest : SqlCeTest
{
[SetUp]
public void SetuUp()
{
WithRealDb();
}
[Test]
public void SetupDefault_should_add_all_profiles()
{
Mocker.Resolve<QualityTypeProvider>();
var types = Mocker.Resolve<QualityTypeProvider>().All();
types.Should().HaveCount(10);
types.Should().Contain(e => e.Name == "SDTV" && e.QualityTypeId == 1);
types.Should().Contain(e => e.Name == "DVD" && e.QualityTypeId == 2);
types.Should().Contain(e => e.Name == "WEBDL-480p" && e.QualityTypeId == 8);
types.Should().Contain(e => e.Name == "HDTV-720p" && e.QualityTypeId == 4);
types.Should().Contain(e => e.Name == "HDTV-1080p" && e.QualityTypeId == 9);
types.Should().Contain(e => e.Name == "Raw-HD" && e.QualityTypeId == 10);
types.Should().Contain(e => e.Name == "WEBDL-720p" && e.QualityTypeId == 5);
types.Should().Contain(e => e.Name == "WEBDL-1080p" && e.QualityTypeId == 3);
types.Should().Contain(e => e.Name == "Bluray720p" && e.QualityTypeId == 6);
types.Should().Contain(e => e.Name == "Bluray1080p" && e.QualityTypeId == 7);
}
[Test]
public void SetupDefault_already_exists_should_insert_missing()
{
Db.Insert(new QualityType { QualityTypeId = 1, Name = "SDTV", MinSize = 0, MaxSize = 100 });
Mocker.Resolve<QualityTypeProvider>();
var types = Mocker.Resolve<QualityTypeProvider>().All();
types.Should().HaveCount(QualityTypes.All().Count - 1);
}
[Test]
public void GetList_single_quality_type()
{
var fakeQualityTypes = Builder<QualityType>.CreateListOfSize(6)
.Build();
var ids = new List<int> { 1 };
Db.InsertMany(fakeQualityTypes);
var result = Mocker.Resolve<QualityTypeProvider>().GetList(ids);
result.Should().HaveCount(ids.Count);
}
[Test]
public void GetList_multiple_quality_type()
{
var fakeQualityTypes = Builder<QualityType>.CreateListOfSize(6)
.Build();
var ids = new List<int> { 1, 2 };
Db.InsertMany(fakeQualityTypes);
var result = Mocker.Resolve<QualityTypeProvider>().GetList(ids);
result.Should().HaveCount(ids.Count);
}
}
}

View File

@ -15,7 +15,6 @@
using NzbDrone.Core.Providers;
using NzbDrone.Core.Providers.Core;
using NzbDrone.Core.Repository;
using NzbDrone.Core.Repository.Quality;
using NzbDrone.Core.Test.Framework;
using NzbDrone.Test.Common.AutoMoq;
using PetaPoco;

View File

@ -15,7 +15,6 @@
using NzbDrone.Core.Providers;
using NzbDrone.Core.Providers.Core;
using NzbDrone.Core.Repository;
using NzbDrone.Core.Repository.Quality;
using NzbDrone.Core.Test.Framework;
using NzbDrone.Test.Common.AutoMoq;
using PetaPoco;

View File

@ -15,7 +15,6 @@
using NzbDrone.Core.Providers;
using NzbDrone.Core.Providers.Core;
using NzbDrone.Core.Repository;
using NzbDrone.Core.Repository.Quality;
using NzbDrone.Core.Test.Framework;
using NzbDrone.Test.Common.AutoMoq;
using PetaPoco;

View File

@ -15,7 +15,6 @@
using NzbDrone.Core.Providers;
using NzbDrone.Core.Providers.Core;
using NzbDrone.Core.Repository;
using NzbDrone.Core.Repository.Quality;
using NzbDrone.Core.Test.Framework;
using NzbDrone.Test.Common.AutoMoq;
using PetaPoco;

View File

@ -7,6 +7,7 @@
using Moq;
using NUnit.Framework;
using NzbDrone.Core.Download;
using NzbDrone.Core.Qualities;
using NzbDrone.Core.Tv;
using NzbDrone.Core.Model;
using NzbDrone.Core.Model.Notification;
@ -14,7 +15,6 @@
using NzbDrone.Core.DecisionEngine;
using NzbDrone.Core.Providers.Search;
using NzbDrone.Core.Repository;
using NzbDrone.Core.Repository.Quality;
using NzbDrone.Core.Repository.Search;
using NzbDrone.Test.Common;
@ -113,17 +113,17 @@ public void should_process_higher_quality_results_first()
.All()
.With(e => e.SeasonNumber = 1)
.With(e => e.EpisodeNumbers = new List<int> { 1 })
.With(c => c.Quality = new QualityModel(QualityTypes.DVD, true))
.With(c => c.Quality = new QualityModel(Quality.DVD, true))
.With(c => c.Age = 10)
.Random(1)
.With(c => c.Quality = new QualityModel(QualityTypes.Bluray1080p, true))
.With(c => c.Quality = new QualityModel(Quality.Bluray1080p, true))
.With(c => c.Age = 100)
.Build()
.ToList();
Mocker.GetMock<AllowedDownloadSpecification>()
.Setup(s => s.IsSatisfiedBy(It.Is<EpisodeParseResult>(d => d.Quality.Quality == QualityTypes.Bluray1080p)))
.Setup(s => s.IsSatisfiedBy(It.Is<EpisodeParseResult>(d => d.Quality.Quality == Quality.Bluray1080p)))
.Returns(ReportRejectionType.None);
var result = Mocker.Resolve<TestSearch>().ProcessReports(_matchingSeries, new { }, parseResults, _searchHistory, _notification);
@ -147,7 +147,7 @@ public void should_process_newer_reports_first()
.All()
.With(e => e.SeasonNumber = 1)
.With(e => e.EpisodeNumbers = new List<int> { 1 })
.With(c => c.Quality = new QualityModel(QualityTypes.Bluray1080p, true))
.With(c => c.Quality = new QualityModel(Quality.Bluray1080p, true))
.With(c => c.Age = 300)
.Build()
.ToList();
@ -177,7 +177,7 @@ public void should_check_other_reports_when_quality_is_not_wanted()
.All()
.With(e => e.SeasonNumber = 1)
.With(e => e.EpisodeNumbers = new List<int> { 1 })
.With(c => c.Quality = new QualityModel(QualityTypes.DVD, true))
.With(c => c.Quality = new QualityModel(Quality.DVD, true))
.Build()
.ToList();
@ -199,7 +199,7 @@ public void should_should_skip_if_series_is_not_watched()
.All()
.With(e => e.SeasonNumber = 1)
.With(e => e.EpisodeNumbers = new List<int> { 1 })
.With(e => e.Quality = new QualityModel(QualityTypes.HDTV720p, false))
.With(e => e.Quality = new QualityModel(Quality.HDTV720p, false))
.Build()
.ToList();
@ -223,7 +223,7 @@ public void should_skip_if_series_does_not_match_searched_series()
.All()
.With(e => e.SeasonNumber = 1)
.With(e => e.EpisodeNumbers = new List<int> { 1 })
.With(e => e.Quality = new QualityModel(QualityTypes.HDTV720p, false))
.With(e => e.Quality = new QualityModel(Quality.HDTV720p, false))
.Build()
.ToList();
@ -247,7 +247,7 @@ public void should_skip_if_episode_was_already_downloaded()
.All()
.With(e => e.SeasonNumber = 1)
.With(e => e.EpisodeNumbers = new List<int> { 5 })
.With(c => c.Quality = new QualityModel(QualityTypes.DVD, true))
.With(c => c.Quality = new QualityModel(Quality.DVD, true))
.TheLast(1)
.With(e => e.EpisodeNumbers = new List<int> { 1, 2, 3, 4, 5 })
.Build()
@ -275,9 +275,9 @@ public void should_try_next_report_if_download_fails()
.All()
.With(e => e.SeasonNumber = 1)
.With(e => e.EpisodeNumbers = new List<int> { 1 })
.With(c => c.Quality = new QualityModel(QualityTypes.DVD, true))
.With(c => c.Quality = new QualityModel(Quality.DVD, true))
.TheLast(1)
.With(c => c.Quality = new QualityModel(QualityTypes.SDTV, true))
.With(c => c.Quality = new QualityModel(Quality.SDTV, true))
.Build()
.ToList();
@ -285,11 +285,11 @@ public void should_try_next_report_if_download_fails()
WithQualityNeeded();
Mocker.GetMock<DownloadProvider>()
.Setup(s => s.DownloadReport(It.Is<EpisodeParseResult>(d => d.Quality.Quality == QualityTypes.DVD)))
.Setup(s => s.DownloadReport(It.Is<EpisodeParseResult>(d => d.Quality.Quality == Quality.DVD)))
.Returns(false);
Mocker.GetMock<DownloadProvider>()
.Setup(s => s.DownloadReport(It.Is<EpisodeParseResult>(d => d.Quality.Quality == QualityTypes.SDTV)))
.Setup(s => s.DownloadReport(It.Is<EpisodeParseResult>(d => d.Quality.Quality == Quality.SDTV)))
.Returns(true);
//Act
@ -310,10 +310,10 @@ public void should_return_valid_successes_when_one_or_more_downloaded()
.All()
.With(e => e.SeasonNumber = 1)
.With(e => e.EpisodeNumbers = new List<int> { 1 })
.With(c => c.Quality = new QualityModel(QualityTypes.DVD, true))
.With(c => c.Quality = new QualityModel(Quality.DVD, true))
.With(c => c.Age = 10)
.Random(1)
.With(c => c.Quality = new QualityModel(QualityTypes.Bluray1080p, true))
.With(c => c.Quality = new QualityModel(Quality.Bluray1080p, true))
.With(c => c.Age = 100)
.Build()
.ToList();
@ -322,7 +322,7 @@ public void should_return_valid_successes_when_one_or_more_downloaded()
WithSuccessfulDownload();
Mocker.GetMock<AllowedDownloadSpecification>()
.Setup(s => s.IsSatisfiedBy(It.Is<EpisodeParseResult>(d => d.Quality.Quality == QualityTypes.Bluray1080p)))
.Setup(s => s.IsSatisfiedBy(It.Is<EpisodeParseResult>(d => d.Quality.Quality == Quality.Bluray1080p)))
.Returns(ReportRejectionType.None);
//Act

View File

@ -10,7 +10,6 @@
using NzbDrone.Core.Model.Notification;
using NzbDrone.Core.Providers;
using NzbDrone.Core.Repository;
using NzbDrone.Core.Repository.Quality;
using NzbDrone.Core.Test.Framework;
using NzbDrone.Test.Common.AutoMoq;
using NzbDrone.Test.Common;

View File

@ -10,7 +10,6 @@
using NzbDrone.Core.Model.Notification;
using NzbDrone.Core.Providers;
using NzbDrone.Core.Repository;
using NzbDrone.Core.Repository.Quality;
using NzbDrone.Core.Test.Framework;
using NzbDrone.Test.Common.AutoMoq;
using NzbDrone.Test.Common;

View File

@ -1,47 +1,44 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using FluentAssertions;
using NUnit.Framework;
using NzbDrone.Core.Model;
using NzbDrone.Core.Repository.Quality;
using NzbDrone.Core.Qualities;
using NzbDrone.Core.Test.Framework;
namespace NzbDrone.Core.Test
namespace NzbDrone.Core.Test.Qualities
{
[TestFixture]
// ReSharper disable InconsistentNaming
public class QualityTypesTest : CoreTest
public class QualityFixture : CoreTest
{
public static object[] FromIntCases =
{
new object[] {1, QualityTypes.SDTV},
new object[] {2, QualityTypes.DVD},
new object[] {4, QualityTypes.HDTV720p},
new object[] {5, QualityTypes.WEBDL720p},
new object[] {6, QualityTypes.Bluray720p},
new object[] {7, QualityTypes.Bluray1080p}
new object[] {1, Quality.SDTV},
new object[] {2, Quality.DVD},
new object[] {4, Quality.HDTV720p},
new object[] {5, Quality.WEBDL720p},
new object[] {6, Quality.Bluray720p},
new object[] {7, Quality.Bluray1080p}
};
public static object[] ToIntCases =
{
new object[] {QualityTypes.SDTV, 1},
new object[] {QualityTypes.DVD, 2},
new object[] {QualityTypes.HDTV720p, 4},
new object[] {QualityTypes.WEBDL720p, 5},
new object[] {QualityTypes.Bluray720p, 6},
new object[] {QualityTypes.Bluray1080p, 7}
new object[] {Quality.SDTV, 1},
new object[] {Quality.DVD, 2},
new object[] {Quality.HDTV720p, 4},
new object[] {Quality.WEBDL720p, 5},
new object[] {Quality.Bluray720p, 6},
new object[] {Quality.Bluray1080p, 7}
};
[Test, TestCaseSource("FromIntCases")]
public void should_be_able_to_convert_int_to_qualityTypes(int source, QualityTypes expected)
public void should_be_able_to_convert_int_to_qualityTypes(int source, Quality expected)
{
var quality = (QualityTypes)source;
var quality = (Quality)source;
quality.Should().Be(expected);
}
[Test, TestCaseSource("ToIntCases")]
public void should_be_able_to_convert_qualityTypes_to_int(QualityTypes source, int expected)
public void should_be_able_to_convert_qualityTypes_to_int(Quality source, int expected)
{
var i = (int)source;
i.Should().Be(expected);
@ -51,8 +48,8 @@ public void should_be_able_to_convert_qualityTypes_to_int(QualityTypes source, i
[Test]
public void Icomparer_greater_test()
{
var first = QualityTypes.DVD;
var second = QualityTypes.Bluray1080p;
var first = Quality.DVD;
var second = Quality.Bluray1080p;
second.Should().BeGreaterThan(first);
}
@ -60,8 +57,8 @@ public void Icomparer_greater_test()
[Test]
public void Icomparer_lesser()
{
var first = QualityTypes.DVD;
var second = QualityTypes.Bluray1080p;
var first = Quality.DVD;
var second = Quality.Bluray1080p;
first.Should().BeLessThan(second);
}
@ -69,8 +66,8 @@ public void Icomparer_lesser()
[Test]
public void equal_operand()
{
var first = QualityTypes.Bluray1080p;
var second = QualityTypes.Bluray1080p;
var first = Quality.Bluray1080p;
var second = Quality.Bluray1080p;
(first == second).Should().BeTrue();
(first >= second).Should().BeTrue();
@ -80,8 +77,8 @@ public void equal_operand()
[Test]
public void equal_operand_false()
{
var first = QualityTypes.Bluray1080p;
var second = QualityTypes.Unknown;
var first = Quality.Bluray1080p;
var second = Quality.Unknown;
(first == second).Should().BeFalse();
}
@ -89,8 +86,8 @@ public void equal_operand_false()
[Test]
public void not_equal_operand()
{
var first = QualityTypes.Bluray1080p;
var second = QualityTypes.Bluray1080p;
var first = Quality.Bluray1080p;
var second = Quality.Bluray1080p;
(first != second).Should().BeFalse();
}
@ -98,8 +95,8 @@ public void not_equal_operand()
[Test]
public void not_equal_operand_false()
{
var first = QualityTypes.Bluray1080p;
var second = QualityTypes.Unknown;
var first = Quality.Bluray1080p;
var second = Quality.Unknown;
(first != second).Should().BeTrue();
}
@ -107,8 +104,8 @@ public void not_equal_operand_false()
[Test]
public void greater_operand()
{
var first = QualityTypes.DVD;
var second = QualityTypes.Bluray1080p;
var first = Quality.DVD;
var second = Quality.Bluray1080p;
(first < second).Should().BeTrue();
(first <= second).Should().BeTrue();
@ -117,8 +114,8 @@ public void greater_operand()
[Test]
public void lesser_operand()
{
var first = QualityTypes.DVD;
var second = QualityTypes.Bluray1080p;
var first = Quality.DVD;
var second = Quality.Bluray1080p;
(second > first).Should().BeTrue();
(second >= first).Should().BeTrue();

View File

@ -0,0 +1,44 @@
// ReSharper disable RedundantUsingDirective
using System.Linq;
using System;
using System.Collections.Generic;
using FizzWare.NBuilder;
using FluentAssertions;
using Moq;
using NUnit.Framework;
using NzbDrone.Core.Qualities;
using NzbDrone.Core.Tv;
using NzbDrone.Core.Test.Framework;
namespace NzbDrone.Core.Test.Qualities
{
[TestFixture]
// ReSharper disable InconsistentNaming
public class QualityProfileFixture : CoreTest<QualityProfileService>
{
[Test]
public void Init_should_add_two_profiles()
{
Subject.Init();
Mocker.GetMock<IQualityProfileRepository>()
.Verify(v => v.Insert(It.IsAny<QualityProfile>()), Times.Exactly(2));
}
[Test]
//This confirms that new profiles are added only if no other profiles exists.
//We don't want to keep adding them back if a user deleted them on purpose.
public void Init_should_skip_if_any_profiles_already_exist()
{
Mocker.GetMock<IQualityProfileRepository>()
.Setup(s => s.All())
.Returns(Builder<QualityProfile>.CreateListOfSize(2).Build().ToList());
Subject.Init();
Mocker.GetMock<IQualityProfileRepository>()
.Verify(v => v.Insert(It.IsAny<QualityProfile>()), Times.Never());
}
}
}

View File

@ -0,0 +1,59 @@
// ReSharper disable RedundantUsingDirective
using System.Linq;
using System.Collections.Generic;
using FizzWare.NBuilder;
using FluentAssertions;
using Moq;
using NUnit.Framework;
using NzbDrone.Core.Qualities;
using NzbDrone.Core.Test.Framework;
namespace NzbDrone.Core.Test.Qualities
{
[TestFixture]
// ReSharper disable InconsistentNaming
public class QualitySizeServiceFixture : CoreTest<QualitySizeService>
{
[Test]
public void Init_should_add_all_sizes()
{
Subject.Init();
Mocker.GetMock<IQualitySizeRepository>()
.Verify(v => v.Insert(It.IsAny<QualitySize>()), Times.Exactly(Quality.All().Count - 1));
//Todo: Should we validate each was inserted exactly as configured?
//var types = Mocker.Resolve<QualitySizeService>().All();
//types.Should().HaveCount(10);
//types.Should().Contain(e => e.Name == "SDTV" && e.QualityId == 1);
//types.Should().Contain(e => e.Name == "DVD" && e.QualityId == 2);
//types.Should().Contain(e => e.Name == "WEBDL-480p" && e.QualityId == 8);
//types.Should().Contain(e => e.Name == "HDTV-720p" && e.QualityId == 4);
//types.Should().Contain(e => e.Name == "HDTV-1080p" && e.QualityId == 9);
//types.Should().Contain(e => e.Name == "Raw-HD" && e.QualityId == 10);
//types.Should().Contain(e => e.Name == "WEBDL-720p" && e.QualityId == 5);
//types.Should().Contain(e => e.Name == "WEBDL-1080p" && e.QualityId == 3);
//types.Should().Contain(e => e.Name == "Bluray720p" && e.QualityId == 6);
//types.Should().Contain(e => e.Name == "Bluray1080p" && e.QualityId == 7);
}
[Test]
public void Init_should_insert_any_missing_sizes()
{
Mocker.GetMock<IQualitySizeRepository>()
.Setup(s => s.All())
.Returns(new List<QualitySize>
{
new QualitySize { QualityId = 1, Name = "SDTV", MinSize = 0, MaxSize = 100 }
});
Subject.Init();
Mocker.GetMock<IQualitySizeRepository>()
.Verify(v => v.Insert(It.IsAny<QualitySize>()), Times.Exactly(Quality.All().Count - 2));
}
}
}

View File

@ -1,158 +0,0 @@
// ReSharper disable RedundantUsingDirective
using System;
using System.Collections.Generic;
using FizzWare.NBuilder;
using FluentAssertions;
using NUnit.Framework;
using NzbDrone.Core.Tv;
using NzbDrone.Core.Providers;
using NzbDrone.Core.Repository;
using NzbDrone.Core.Repository.Quality;
using NzbDrone.Core.Test.Framework;
using NzbDrone.Test.Common.AutoMoq;
namespace NzbDrone.Core.Test
{
[TestFixture]
// ReSharper disable InconsistentNaming
public class QualityProfileTest : SqlCeTest<QualityProvider>
{
[SetUp]
public void SetUp()
{
WithRealDb();
}
[Test]
public void Test_Storage()
{
//Arrange
var testProfile = new QualityProfile
{
Name = Guid.NewGuid().ToString(),
Cutoff = QualityTypes.SDTV,
Allowed = new List<QualityTypes> { QualityTypes.HDTV720p, QualityTypes.DVD },
};
var id = Convert.ToInt32(Db.Insert(testProfile));
var fetch = Db.SingleOrDefault<QualityProfile>(id);
Assert.AreEqual(id, fetch.QualityProfileId);
Assert.AreEqual(testProfile.Name, fetch.Name);
Assert.AreEqual(testProfile.Cutoff, fetch.Cutoff);
Assert.AreEqual(testProfile.Allowed, fetch.Allowed);
}
[Test]
public void Test_Storage_no_allowed()
{
//Arrange
var testProfile = new QualityProfile
{
Name = Guid.NewGuid().ToString(),
Cutoff = QualityTypes.SDTV
};
var id = Convert.ToInt32(Db.Insert(testProfile));
var fetch = Db.SingleOrDefault<QualityProfile>(id);
Assert.AreEqual(id, fetch.QualityProfileId);
Assert.AreEqual(testProfile.Name, fetch.Name);
Assert.AreEqual(testProfile.Cutoff, fetch.Cutoff);
fetch.Allowed.Should().HaveCount(0);
}
[Test]
public void Update_Success()
{
var testProfile = new QualityProfile
{
Name = Guid.NewGuid().ToString(),
Cutoff = QualityTypes.SDTV
};
var id = Convert.ToInt32(Db.Insert(testProfile));
var currentProfile = Db.SingleOrDefault<QualityProfile>(id);
//Update
currentProfile.Cutoff = QualityTypes.Bluray720p;
Mocker.Resolve<QualityProvider>().Update(currentProfile);
var updated = Mocker.Resolve<QualityProvider>().Get(currentProfile.QualityProfileId);
updated.Name.Should().Be(currentProfile.Name);
updated.Cutoff.Should().Be(QualityTypes.Bluray720p);
updated.AllowedString.Should().Be(currentProfile.AllowedString);
}
[Test]
public void Test_Series_Quality()
{
var testProfile = new QualityProfile
{
Name = Guid.NewGuid().ToString(),
Cutoff = QualityTypes.SDTV,
Allowed = new List<QualityTypes> { QualityTypes.HDTV720p, QualityTypes.DVD },
};
var profileId = Convert.ToInt32(Db.Insert(testProfile));
var series = Builder<Series>.CreateNew().Build();
series.QualityProfileId = profileId;
Db.Insert(testProfile);
Db.Insert(series);
var result = Db.Fetch<Series>();
result.Should().HaveCount(1);
var profile = Db.SingleOrDefault<QualityProfile>(result[0].QualityProfileId);
Assert.AreEqual(profileId, result[0].QualityProfileId);
Assert.AreEqual(testProfile.Name, profile.Name);
}
[Test]
public void SetupInitial_should_add_two_profiles()
{
Mocker.Resolve<QualityProvider>();
var profiles = Mocker.Resolve<QualityProvider>().All();
profiles.Should().HaveCount(2);
profiles.Should().Contain(e => e.Name == "HD");
profiles.Should().Contain(e => e.Name == "SD");
}
[Test]
//This confirms that new profiles are added only if no other profiles exists.
//We don't want to keep adding them back if a user deleted them on purpose.
public void SetupInitial_should_skip_if_any_profile_exists()
{
InitiateSubject();
var profiles = Subject.All();
Subject.Delete(profiles[0].QualityProfileId);
InitiateSubject();
Subject.All().Should().HaveCount(profiles.Count - 1);
}
}
}

View File

@ -9,11 +9,11 @@
using NUnit.Framework;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Download;
using NzbDrone.Core.Qualities;
using NzbDrone.Core.Tv;
using NzbDrone.Core.Model;
using NzbDrone.Core.Providers;
using NzbDrone.Core.Providers.Core;
using NzbDrone.Core.Repository.Quality;
using NzbDrone.Core.Test.Framework;
using PetaPoco;
using TvdbLib.Data;
@ -86,7 +86,7 @@ public void GetEpisode_with_EpisodeFile()
WithRealDb();
var fakeSeries = Builder<Series>.CreateNew().Build();
var fakeFile = Builder<EpisodeFile>.CreateNew().With(f => f.EpisodeFileId).With(c => c.Quality = QualityTypes.SDTV).Build();
var fakeFile = Builder<EpisodeFile>.CreateNew().With(f => f.EpisodeFileId).With(c => c.Quality = Quality.SDTV).Build();
var fakeEpisodes = Builder<Episode>.CreateListOfSize(5)
.All().With(e => e.SeriesId = 1).TheFirst(1).With(e => e.EpisodeFile = new EpisodeFile { EpisodeFileId = 1 }).With(e => e.EpisodeFile = fakeFile).Build();
@ -857,7 +857,7 @@ public void GetEpisode_by_Season_Episode_with_EpisodeFile()
WithRealDb();
var fakeSeries = Builder<Series>.CreateNew().Build();
var fakeFile = Builder<EpisodeFile>.CreateNew().With(f => f.EpisodeFileId).With(c => c.Quality = QualityTypes.SDTV).Build();
var fakeFile = Builder<EpisodeFile>.CreateNew().With(f => f.EpisodeFileId).With(c => c.Quality = Quality.SDTV).Build();
var fakeEpisodes = Builder<Episode>.CreateListOfSize(5)
.All().With(e => e.SeriesId = 1).TheFirst(1).With(c => c.EpisodeFile = new EpisodeFile { EpisodeFileId = 1 }).With(e => e.EpisodeFile = fakeFile).Build();
@ -901,7 +901,7 @@ public void GetEpisode_by_AirDate_with_EpisodeFile()
WithRealDb();
var fakeSeries = Builder<Series>.CreateNew().Build();
var fakeFile = Builder<EpisodeFile>.CreateNew().With(f => f.EpisodeFileId).With(c => c.Quality = QualityTypes.SDTV).Build();
var fakeFile = Builder<EpisodeFile>.CreateNew().With(f => f.EpisodeFileId).With(c => c.Quality = Quality.SDTV).Build();
var fakeEpisodes = Builder<Episode>.CreateListOfSize(5)
.All().With(e => e.SeriesId = 1).TheFirst(1).With(e => e.EpisodeFile = new EpisodeFile { EpisodeFileId = 1 }).With(e => e.EpisodeFile = fakeFile).Build();
@ -1213,7 +1213,7 @@ public void EpisodesWithFiles_success()
var episodeFile = Builder<EpisodeFile>.CreateNew()
.With(c => c.EpisodeFileId = 1)
.With(c => c.Quality = QualityTypes.SDTV)
.With(c => c.Quality = Quality.SDTV)
.Build();
var episodes = Builder<Episode>.CreateListOfSize(2)

View File

@ -1,21 +1,21 @@
using FluentAssertions;
using System.Linq;
using FluentAssertions;
using NUnit.Framework;
using NzbDrone.Core.Qualities;
using NzbDrone.Core.Tv;
using NzbDrone.Core.Model;
using NzbDrone.Core.Repository.Quality;
using NzbDrone.Core.Test.Framework;
namespace NzbDrone.Core.Test
namespace NzbDrone.Core.Test.TvTests
{
[TestFixture]
// ReSharper disable InconsistentNaming
public class QualityTest : CoreTest
public class QualityModelFixture : CoreTest
{
[Test]
public void Icomparer_greater_test()
{
var first = new QualityModel(QualityTypes.DVD, true);
var second = new QualityModel(QualityTypes.Bluray1080p, true);
var first = new QualityModel(Quality.DVD, true);
var second = new QualityModel(Quality.Bluray1080p, true);
second.Should().BeGreaterThan(first);
}
@ -23,8 +23,8 @@ public void Icomparer_greater_test()
[Test]
public void Icomparer_greater_proper()
{
var first = new QualityModel(QualityTypes.Bluray1080p, false);
var second = new QualityModel(QualityTypes.Bluray1080p, true);
var first = new QualityModel(Quality.Bluray1080p, false);
var second = new QualityModel(Quality.Bluray1080p, true);
second.Should().BeGreaterThan(first);
}
@ -32,8 +32,8 @@ public void Icomparer_greater_proper()
[Test]
public void Icomparer_lesser()
{
var first = new QualityModel(QualityTypes.DVD, true);
var second = new QualityModel(QualityTypes.Bluray1080p, true);
var first = new QualityModel(Quality.DVD, true);
var second = new QualityModel(Quality.Bluray1080p, true);
first.Should().BeLessThan(second);
}
@ -41,8 +41,8 @@ public void Icomparer_lesser()
[Test]
public void Icomparer_lesser_proper()
{
var first = new QualityModel(QualityTypes.DVD, false);
var second = new QualityModel(QualityTypes.DVD, true);
var first = new QualityModel(Quality.DVD, false);
var second = new QualityModel(Quality.DVD, true);
first.Should().BeLessThan(second);
}
@ -50,8 +50,8 @@ public void Icomparer_lesser_proper()
[Test]
public void equal_operand()
{
var first = new QualityModel(QualityTypes.Bluray1080p, true);
var second = new QualityModel(QualityTypes.Bluray1080p, true);
var first = new QualityModel(Quality.Bluray1080p, true);
var second = new QualityModel(Quality.Bluray1080p, true);
(first == second).Should().BeTrue();
(first >= second).Should().BeTrue();
@ -61,8 +61,8 @@ public void equal_operand()
[Test]
public void equal_operand_false()
{
var first = new QualityModel(QualityTypes.Bluray1080p, true);
var second = new QualityModel(QualityTypes.Unknown, true);
var first = new QualityModel(Quality.Bluray1080p, true);
var second = new QualityModel(Quality.Unknown, true);
(first == second).Should().BeFalse();
}
@ -70,8 +70,8 @@ public void equal_operand_false()
[Test]
public void equal_operand_false_proper()
{
var first = new QualityModel(QualityTypes.Bluray1080p, true);
var second = new QualityModel(QualityTypes.Bluray1080p, false);
var first = new QualityModel(Quality.Bluray1080p, true);
var second = new QualityModel(Quality.Bluray1080p, false);
(first == second).Should().BeFalse();
}
@ -79,8 +79,8 @@ public void equal_operand_false_proper()
[Test]
public void not_equal_operand()
{
var first = new QualityModel(QualityTypes.Bluray1080p, true);
var second = new QualityModel(QualityTypes.Bluray1080p, true);
var first = new QualityModel(Quality.Bluray1080p, true);
var second = new QualityModel(Quality.Bluray1080p, true);
(first != second).Should().BeFalse();
}
@ -88,8 +88,8 @@ public void not_equal_operand()
[Test]
public void not_equal_operand_false()
{
var first = new QualityModel(QualityTypes.Bluray1080p, true);
var second = new QualityModel(QualityTypes.Unknown, true);
var first = new QualityModel(Quality.Bluray1080p, true);
var second = new QualityModel(Quality.Unknown, true);
(first != second).Should().BeTrue();
}
@ -97,8 +97,8 @@ public void not_equal_operand_false()
[Test]
public void not_equal_operand_false_proper()
{
var first = new QualityModel(QualityTypes.Bluray1080p, true);
var second = new QualityModel(QualityTypes.Bluray1080p, false);
var first = new QualityModel(Quality.Bluray1080p, true);
var second = new QualityModel(Quality.Bluray1080p, false);
(first != second).Should().BeTrue();
}
@ -106,8 +106,8 @@ public void not_equal_operand_false_proper()
[Test]
public void greater_operand()
{
var first = new QualityModel(QualityTypes.DVD, true);
var second = new QualityModel(QualityTypes.Bluray1080p, true);
var first = new QualityModel(Quality.DVD, true);
var second = new QualityModel(Quality.Bluray1080p, true);
(first < second).Should().BeTrue();
(first <= second).Should().BeTrue();
@ -116,12 +116,11 @@ public void greater_operand()
[Test]
public void lesser_operand()
{
var first = new QualityModel(QualityTypes.DVD, true);
var second = new QualityModel(QualityTypes.Bluray1080p, true);
var first = new QualityModel(Quality.DVD, true);
var second = new QualityModel(Quality.Bluray1080p, true);
(second > first).Should().BeTrue();
(second >= first).Should().BeTrue();
}
}
}

View File

@ -5,7 +5,6 @@
using FluentAssertions;
using NUnit.Framework;
using NzbDrone.Core.Model.Xbmc;
using NzbDrone.Core.Repository.Quality;
namespace NzbDrone.Core.Test
{

View File

@ -1,6 +1,6 @@
using System;
using System.Reflection;
using NzbDrone.Core.Repository.Quality;
using NzbDrone.Core.Qualities;
using PetaPoco;
namespace NzbDrone.Core.Datastore
@ -9,11 +9,11 @@ public class CustomeMapper : DefaultMapper
{
public override Func<object, object> GetToDbConverter(Type sourceType)
{
if (sourceType == typeof(QualityTypes))
if (sourceType == typeof(Quality))
{
return delegate(object s)
{
var source = (QualityTypes)s;
var source = (Quality)s;
return source.Id;
};
}
@ -45,13 +45,13 @@ public override Func<object, object> GetFromDbConverter(Type destinationType, Ty
};
}
if ((sourceType == typeof(Int32) || sourceType == typeof(Int64)) && destinationType == typeof(QualityTypes))
if ((sourceType == typeof(Int32) || sourceType == typeof(Int64)) && destinationType == typeof(Quality))
{
return delegate(object s)
{
int value;
Int32.TryParse(s.ToString(), out value);
var quality = (QualityTypes)value;
var quality = (Quality)value;
return quality;
};
}

View File

@ -1,20 +1,20 @@
using System.Linq;
using NLog;
using NzbDrone.Core.Datastore;
using NzbDrone.Core.Qualities;
using NzbDrone.Core.Tv;
using NzbDrone.Core.Model;
using NzbDrone.Core.Providers;
using NzbDrone.Core.Repository.Quality;
namespace NzbDrone.Core.DecisionEngine
{
public class AcceptableSizeSpecification
{
private readonly QualityTypeProvider _qualityTypeProvider;
private readonly QualitySizeService _qualityTypeProvider;
private readonly IEpisodeService _episodeService;
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
public AcceptableSizeSpecification(QualityTypeProvider qualityTypeProvider, IEpisodeService episodeService)
public AcceptableSizeSpecification(QualitySizeService qualityTypeProvider, IEpisodeService episodeService)
{
_qualityTypeProvider = qualityTypeProvider;
_episodeService = episodeService;
@ -29,7 +29,7 @@ public virtual bool IsSatisfiedBy(EpisodeParseResult subject)
{
logger.Trace("Beginning size check for: {0}", subject);
if(subject.Quality.Quality == QualityTypes.RAWHD)
if(subject.Quality.Quality == Quality.RAWHD)
{
logger.Trace("Raw-HD release found, skipping size check.");
return true;

View File

@ -1,8 +1,8 @@
using System.Linq;
using NLog;
using NzbDrone.Core.Qualities;
using NzbDrone.Core.Tv;
using NzbDrone.Core.Model;
using NzbDrone.Core.Repository.Quality;
namespace NzbDrone.Core.DecisionEngine
{
@ -10,7 +10,7 @@ public class QualityUpgradeSpecification
{
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
public virtual bool IsSatisfiedBy(QualityModel currentQuality, QualityModel newQuality, QualityTypes cutOff)
public virtual bool IsSatisfiedBy(QualityModel currentQuality, QualityModel newQuality, Quality cutOff)
{
if (currentQuality >= newQuality)
{

View File

@ -1,5 +1,6 @@
using System.Linq;
using NLog;
using NzbDrone.Core.Qualities;
using NzbDrone.Core.Tv;
using NzbDrone.Core.Providers;
using NzbDrone.Core.Repository;
@ -8,10 +9,10 @@ namespace NzbDrone.Core.DecisionEngine
{
public class UpgradePossibleSpecification
{
private readonly QualityProvider _qualityProvider;
private readonly IQualityProfileService _qualityProvider;
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
public UpgradePossibleSpecification(QualityProvider qualityProvider)
public UpgradePossibleSpecification(IQualityProfileService qualityProvider)
{
_qualityProvider = qualityProvider;
}

View File

@ -307,6 +307,8 @@
<Compile Include="Model\JobQueueItem.cs" />
<Compile Include="Model\LanguageType.cs" />
<Compile Include="Model\MisnamedEpisodeModel.cs" />
<Compile Include="Qualities\QualitySizeRepository.cs" />
<Compile Include="Qualities\QualityProfileRepository.cs" />
<Compile Include="Tv\EpisodeService.cs" />
<Compile Include="Tv\Events\SeriesAddedEvent.cs" />
<Compile Include="Tv\SeasonRepository.cs" />
@ -390,7 +392,7 @@
<Compile Include="Providers\XemCommunicationProvider.cs" />
<Compile Include="Providers\XemProvider.cs" />
<Compile Include="Repository\MetadataDefinition.cs" />
<Compile Include="Repository\Quality\QualityTypes.cs" />
<Compile Include="Qualities\Quality.cs" />
<Compile Include="Repository\Search\SearchHistoryItem.cs" />
<Compile Include="Repository\Search\SearchHistory.cs" />
<Compile Include="Model\ReportRejectionType.cs" />
@ -525,10 +527,10 @@
<Compile Include="Providers\ProwlProvider.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Providers\QualityProvider.cs">
<Compile Include="Qualities\QualityProfileService.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Providers\QualityTypeProvider.cs">
<Compile Include="Qualities\QualitySizeService.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Providers\ReferenceDataProvider.cs">
@ -590,8 +592,8 @@
<Compile Include="Tv\Episode.cs" />
<Compile Include="Instrumentation\Log.cs" />
<Compile Include="History\History.cs" />
<Compile Include="Repository\Quality\QualityType.cs" />
<Compile Include="Repository\Quality\QualityProfile.cs" />
<Compile Include="Qualities\QualitySize.cs" />
<Compile Include="Qualities\QualityProfile.cs" />
<Compile Include="RootFolders\RootFolder.cs" />
<Compile Include="Repository\SceneMapping.cs" />
<Compile Include="Tv\Series.cs" />

View File

@ -6,9 +6,9 @@
using System.Text.RegularExpressions;
using NLog;
using NzbDrone.Common;
using NzbDrone.Core.Qualities;
using NzbDrone.Core.Tv;
using NzbDrone.Core.Model;
using NzbDrone.Core.Repository.Quality;
namespace NzbDrone.Core
{
@ -257,12 +257,12 @@ internal static QualityModel ParseQuality(string name)
name = name.Trim();
var normalizedName = NormalizeTitle(name);
var result = new QualityModel { Quality = QualityTypes.Unknown };
var result = new QualityModel { Quality = Quality.Unknown };
result.Proper = (normalizedName.Contains("proper") || normalizedName.Contains("repack"));
if (normalizedName.Contains("dvd") || normalizedName.Contains("bdrip") || normalizedName.Contains("brrip"))
{
result.Quality = QualityTypes.DVD;
result.Quality = Quality.DVD;
return result;
}
@ -270,11 +270,11 @@ internal static QualityModel ParseQuality(string name)
{
if (normalizedName.Contains("bluray"))
{
result.Quality = QualityTypes.DVD;
result.Quality = Quality.DVD;
return result;
}
result.Quality = QualityTypes.SDTV;
result.Quality = Quality.SDTV;
return result;
}
@ -282,46 +282,46 @@ internal static QualityModel ParseQuality(string name)
{
if (normalizedName.Contains("720p"))
{
result.Quality = QualityTypes.Bluray720p;
result.Quality = Quality.Bluray720p;
return result;
}
if (normalizedName.Contains("1080p"))
{
result.Quality = QualityTypes.Bluray1080p;
result.Quality = Quality.Bluray1080p;
return result;
}
result.Quality = QualityTypes.Bluray720p;
result.Quality = Quality.Bluray720p;
return result;
}
if (normalizedName.Contains("webdl"))
{
if (normalizedName.Contains("1080p"))
{
result.Quality = QualityTypes.WEBDL1080p;
result.Quality = Quality.WEBDL1080p;
return result;
}
if (normalizedName.Contains("720p"))
{
result.Quality = QualityTypes.WEBDL720p;
result.Quality = Quality.WEBDL720p;
return result;
}
if(name.Contains("[WEBDL]"))
{
result.Quality = QualityTypes.WEBDL720p;
result.Quality = Quality.WEBDL720p;
return result;
}
result.Quality = QualityTypes.WEBDL480p;
result.Quality = Quality.WEBDL480p;
return result;
}
if (normalizedName.Contains("trollhd") || normalizedName.Contains("rawhd"))
{
result.Quality = QualityTypes.RAWHD;
result.Quality = Quality.RAWHD;
return result;
}
@ -329,16 +329,16 @@ internal static QualityModel ParseQuality(string name)
{
if(normalizedName.Contains("1080p"))
{
result.Quality = QualityTypes.HDTV1080p;
result.Quality = Quality.HDTV1080p;
return result;
}
result.Quality = QualityTypes.HDTV720p;
result.Quality = Quality.HDTV720p;
return result;
}
//Based on extension
if (result.Quality == QualityTypes.Unknown)
if (result.Quality == Quality.Unknown)
{
try
{
@ -359,13 +359,13 @@ internal static QualityModel ParseQuality(string name)
case ".ogm":
case ".strm":
{
result.Quality = QualityTypes.SDTV;
result.Quality = Quality.SDTV;
break;
}
case ".mkv":
case ".ts":
{
result.Quality = QualityTypes.HDTV720p;
result.Quality = Quality.HDTV720p;
break;
}
}
@ -379,21 +379,21 @@ internal static QualityModel ParseQuality(string name)
if (name.Contains("[HDTV]"))
{
result.Quality = QualityTypes.HDTV720p;
result.Quality = Quality.HDTV720p;
return result;
}
if (normalizedName.Contains("hdtv") && normalizedName.Contains("1080p"))
{
result.Quality = QualityTypes.HDTV1080p;
result.Quality = Quality.HDTV1080p;
return result;
}
if ((normalizedName.Contains("sdtv") || normalizedName.Contains("pdtv") ||
(result.Quality == QualityTypes.Unknown && normalizedName.Contains("hdtv"))) &&
(result.Quality == Quality.Unknown && normalizedName.Contains("hdtv"))) &&
!normalizedName.Contains("mpeg"))
{
result.Quality = QualityTypes.SDTV;
result.Quality = Quality.SDTV;
return result;
}

View File

@ -4,11 +4,11 @@
using System.Linq;
using NLog;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Qualities;
using NzbDrone.Core.Tv;
using NzbDrone.Core.Helpers;
using NzbDrone.Core.Providers.Core;
using NzbDrone.Core.Repository;
using NzbDrone.Core.Repository.Quality;
using PetaPoco;
using NzbDrone.Common;
@ -142,7 +142,7 @@ LEFT OUTER JOIN Episodes
}
}
public virtual string GetNewFilename(IList<Episode> episodes, Series series, QualityTypes quality, bool proper, EpisodeFile episodeFile)
public virtual string GetNewFilename(IList<Episode> episodes, Series series, Quality quality, bool proper, EpisodeFile episodeFile)
{
if (_configService.SortingUseSceneName)
{
@ -240,12 +240,12 @@ public virtual string GetNewFilename(IList<Episode> episodes, Series series, Qua
return CleanFilename(result.Trim());
}
public virtual void ChangeQuality(int episodeFileId, QualityTypes quality)
public virtual void ChangeQuality(int episodeFileId, Quality quality)
{
_database.Execute("UPDATE EpisodeFiles SET Quality = @quality WHERE EpisodeFileId = @episodeFileId", new { episodeFileId, quality });
}
public virtual void ChangeQuality(int seriesId, int seasonNumber, QualityTypes quality)
public virtual void ChangeQuality(int seriesId, int seasonNumber, Quality quality)
{
_database.Execute("UPDATE EpisodeFiles SET Quality = @quality WHERE SeriesId = @seriesId AND SeasonNumber = @seasonNumber", new { seriesId, seasonNumber, quality });
}

View File

@ -1,79 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using NLog;
using NzbDrone.Core.Repository.Quality;
using PetaPoco;
namespace NzbDrone.Core.Providers
{
public class QualityProvider
{
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
private readonly IDatabase _database;
public QualityProvider()
{
}
public QualityProvider(IDatabase database)
{
_database = database;
SetupDefaultProfiles();
}
public virtual int Add(QualityProfile profile)
{
return Convert.ToInt32(_database.Insert(profile));
}
public virtual void Update(QualityProfile profile)
{
if (!_database.Exists<QualityProfile>("WHERE QualityProfileid = @0", profile.QualityProfileId))
{
Logger.Error("Unable to update non-existing profile");
throw new InvalidOperationException("Unable to update non-existing profile");
}
_database.Update(profile);
}
public virtual void Delete(int profileId)
{
_database.Delete<QualityProfile>(profileId);
}
public virtual List<QualityProfile> All()
{
var profiles = _database.Fetch<QualityProfile>().ToList();
return profiles;
}
public virtual QualityProfile Get(int profileId)
{
return _database.Single<QualityProfile>(profileId);
}
private void SetupDefaultProfiles()
{
if (All().Count != 0)
return;
Logger.Info("Setting up default quality profiles");
var sd = new QualityProfile { Name = "SD", Allowed = new List<QualityTypes> { QualityTypes.SDTV, QualityTypes.DVD }, Cutoff = QualityTypes.SDTV };
var hd = new QualityProfile
{
Name = "HD",
Allowed = new List<QualityTypes> { QualityTypes.HDTV720p, QualityTypes.WEBDL720p, QualityTypes.Bluray720p },
Cutoff = QualityTypes.HDTV720p
};
Add(sd);
Add(hd);
}
}
}

View File

@ -1,74 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NLog;
using NzbDrone.Core.Repository.Quality;
using PetaPoco;
namespace NzbDrone.Core.Providers
{
public class QualityTypeProvider
{
private readonly IDatabase _database;
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
public QualityTypeProvider(IDatabase database)
{
_database = database;
SetupDefault();
}
public QualityTypeProvider()
{
}
public virtual void Update(QualityType qualityType)
{
_database.Update(qualityType);
}
public virtual void UpdateAll(List<QualityType> qualityTypes)
{
_database.UpdateMany(qualityTypes);
}
public virtual List<QualityType> All()
{
return _database.Fetch<QualityType>();
}
public virtual QualityType Get(int qualityTypeId)
{
return _database.Single<QualityType>(qualityTypeId);
}
public virtual List<QualityType> GetList(List<int> qualityTypeIds)
{
var queryParams = String.Join(", ", qualityTypeIds);
var query = String.Format("WHERE QualityTypeId IN ({0})", queryParams);
return _database.Fetch<QualityType>(query);
}
private void SetupDefault()
{
var inDb = All();
Logger.Debug("Setting up default quality types");
foreach (var qualityType in QualityTypes.All())
{
//Skip UNKNOWN
if (qualityType.Id == 0) continue;
var db = inDb.SingleOrDefault(s => s.QualityTypeId == qualityType.Id);
if (db == null)
_database.Insert(new QualityType { QualityTypeId = qualityType.Id, Name = qualityType.Name, MinSize = 0, MaxSize = 100 });
}
}
}
}

View File

@ -2,15 +2,15 @@
using System.Collections.Generic;
using System.Linq;
namespace NzbDrone.Core.Repository.Quality
namespace NzbDrone.Core.Qualities
{
public class QualityTypes : IComparable<QualityTypes>
public class Quality : IComparable<Quality>
{
public int Id { get; set; }
public string Name { get; set; }
public int Weight { get; set; }
public int CompareTo(QualityTypes other)
public int CompareTo(Quality other)
{
if (other.Weight > Weight)
return -1;
@ -24,12 +24,12 @@ public int CompareTo(QualityTypes other)
return 0;
}
public static bool operator !=(QualityTypes x, QualityTypes y)
public static bool operator !=(Quality x, Quality y)
{
return !(x == y);
}
public static bool operator ==(QualityTypes x, QualityTypes y)
public static bool operator ==(Quality x, Quality y)
{
var xObj = (Object)x;
var yObj = (object)y;
@ -42,22 +42,22 @@ public int CompareTo(QualityTypes other)
return x.CompareTo(y) == 0;
}
public static bool operator >(QualityTypes x, QualityTypes y)
public static bool operator >(Quality x, Quality y)
{
return x.CompareTo(y) > 0;
}
public static bool operator <(QualityTypes x, QualityTypes y)
public static bool operator <(Quality x, Quality y)
{
return x.CompareTo(y) < 0;
}
public static bool operator <=(QualityTypes x, QualityTypes y)
public static bool operator <=(Quality x, Quality y)
{
return x.CompareTo(y) <= 0;
}
public static bool operator >=(QualityTypes x, QualityTypes y)
public static bool operator >=(Quality x, Quality y)
{
return x.CompareTo(y) >= 0;
}
@ -77,7 +77,7 @@ public override int GetHashCode()
}
}
public bool Equals(QualityTypes other)
public bool Equals(Quality other)
{
if (ReferenceEquals(null, other)) return false;
if (ReferenceEquals(this, other)) return true;
@ -88,26 +88,26 @@ public override bool Equals(object obj)
{
if (ReferenceEquals(null, obj)) return false;
if (ReferenceEquals(this, obj)) return true;
if (obj.GetType() != typeof (QualityTypes)) return false;
return Equals((QualityTypes) obj);
if (obj.GetType() != typeof (Quality)) return false;
return Equals((Quality) obj);
}
public static QualityTypes Unknown = new QualityTypes { Id = 0, Name = "Unknown", Weight = 0 };
public static QualityTypes SDTV = new QualityTypes {Id = 1, Name = "SDTV", Weight = 1};
public static QualityTypes WEBDL480p = new QualityTypes { Id = 8, Name = "WEBDL-480p", Weight = 2 };
public static QualityTypes DVD = new QualityTypes { Id = 2, Name = "DVD", Weight = 3 };
public static QualityTypes HDTV720p = new QualityTypes { Id = 4, Name = "HDTV-720p", Weight = 4 };
public static QualityTypes HDTV1080p = new QualityTypes { Id = 9, Name = "HDTV-1080p", Weight = 5 };
public static QualityTypes RAWHD = new QualityTypes { Id = 10, Name = "Raw-HD", Weight = 6 };
public static QualityTypes WEBDL720p = new QualityTypes { Id = 5, Name = "WEBDL-720p", Weight = 7 };
public static QualityTypes Bluray720p = new QualityTypes { Id = 6, Name = "Bluray720p", Weight = 8 };
public static QualityTypes WEBDL1080p = new QualityTypes { Id = 3, Name = "WEBDL-1080p", Weight = 9 };
public static QualityTypes Bluray1080p = new QualityTypes { Id = 7, Name = "Bluray1080p", Weight = 10 };
public static Quality Unknown = new Quality { Id = 0, Name = "Unknown", Weight = 0 };
public static Quality SDTV = new Quality {Id = 1, Name = "SDTV", Weight = 1};
public static Quality WEBDL480p = new Quality { Id = 8, Name = "WEBDL-480p", Weight = 2 };
public static Quality DVD = new Quality { Id = 2, Name = "DVD", Weight = 3 };
public static Quality HDTV720p = new Quality { Id = 4, Name = "HDTV-720p", Weight = 4 };
public static Quality HDTV1080p = new Quality { Id = 9, Name = "HDTV-1080p", Weight = 5 };
public static Quality RAWHD = new Quality { Id = 10, Name = "Raw-HD", Weight = 6 };
public static Quality WEBDL720p = new Quality { Id = 5, Name = "WEBDL-720p", Weight = 7 };
public static Quality Bluray720p = new Quality { Id = 6, Name = "Bluray720p", Weight = 8 };
public static Quality WEBDL1080p = new Quality { Id = 3, Name = "WEBDL-1080p", Weight = 9 };
public static Quality Bluray1080p = new Quality { Id = 7, Name = "Bluray1080p", Weight = 10 };
public static List<QualityTypes> All()
public static List<Quality> All()
{
return new List<QualityTypes>
return new List<Quality>
{
Unknown,
SDTV,
@ -123,7 +123,7 @@ public static List<QualityTypes> All()
};
}
public static QualityTypes FindById(int id)
public static Quality FindById(int id)
{
var quality = All().SingleOrDefault(q => q.Id == id);
@ -133,12 +133,12 @@ public static QualityTypes FindById(int id)
return quality;
}
public static explicit operator QualityTypes(int id)
public static explicit operator Quality(int id)
{
return FindById(id);
}
public static explicit operator int(QualityTypes quality)
public static explicit operator int(Quality quality)
{
return quality.Id;
}

View File

@ -0,0 +1,13 @@
using System.Collections.Generic;
using System.Linq;
using NzbDrone.Core.Datastore;
namespace NzbDrone.Core.Qualities
{
public class QualityProfile : ModelBase
{
public string Name { get; set; }
public List<Quality> Allowed { get; set; }
public Quality Cutoff { get; set; }
}
}

View File

@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NzbDrone.Core.Datastore;
namespace NzbDrone.Core.Qualities
{
public interface IQualityProfileRepository : IBasicRepository<QualityProfile>
{
}
public class QualityProfileRepository : BasicRepository<QualityProfile>, IQualityProfileRepository
{
public QualityProfileRepository(IObjectDatabase database)
: base(database)
{
}
}
}

View File

@ -0,0 +1,76 @@
using System;
using System.Collections.Generic;
using System.Linq;
using NLog;
using NzbDrone.Core.Lifecycle;
using NzbDrone.Core.Qualities;
using PetaPoco;
namespace NzbDrone.Core.Qualities
{
public interface IQualityProfileService
{
QualityProfile Add(QualityProfile profile);
void Update(QualityProfile profile);
void Delete(int id);
List<QualityProfile> All();
QualityProfile Get(int id);
}
public class QualityProfileService : IQualityProfileService, IInitializable
{
private readonly IQualityProfileRepository _qualityProfileRepository;
private readonly Logger _logger;
public QualityProfileService(IQualityProfileRepository qualityProfileRepository, Logger logger)
{
_qualityProfileRepository = qualityProfileRepository;
_logger = logger;
}
public QualityProfile Add(QualityProfile profile)
{
return _qualityProfileRepository.Insert(profile);
}
public void Update(QualityProfile profile)
{
_qualityProfileRepository.Update(profile);
}
public void Delete(int id)
{
_qualityProfileRepository.Delete(id);
}
public List<QualityProfile> All()
{
return _qualityProfileRepository.All().ToList();
}
public QualityProfile Get(int id)
{
return _qualityProfileRepository.Get(id);
}
public void Init()
{
if (All().Count != 0)
return;
_logger.Info("Setting up default quality profiles");
var sd = new QualityProfile { Name = "SD", Allowed = new List<Quality> { Quality.SDTV, Quality.DVD }, Cutoff = Quality.SDTV };
var hd = new QualityProfile
{
Name = "HD",
Allowed = new List<Quality> { Quality.HDTV720p, Quality.WEBDL720p, Quality.Bluray720p },
Cutoff = Quality.HDTV720p
};
Add(sd);
Add(hd);
}
}
}

View File

@ -1,13 +1,12 @@
using System.Linq;
using NzbDrone.Core.Datastore;
using PetaPoco;
namespace NzbDrone.Core.Repository.Quality
namespace NzbDrone.Core.Qualities
{
[TableName("QualityTypes")]
[PrimaryKey("QualityTypeId", autoIncrement = false)]
public class QualityType
public class QualitySize : ModelBase
{
public int QualityTypeId { get; set; }
public int QualityId { get; set; }
public string Name { get; set; }
public int MinSize { get; set; }
public int MaxSize { get; set; }

View File

@ -0,0 +1,26 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NzbDrone.Core.Datastore;
namespace NzbDrone.Core.Qualities
{
public interface IQualitySizeRepository : IBasicRepository<QualitySize>
{
QualitySize GetByQualityId(int qualityId);
}
public class QualitySizeRepository : BasicRepository<QualitySize>, IQualitySizeRepository
{
public QualitySizeRepository(IObjectDatabase database)
: base(database)
{
}
public QualitySize GetByQualityId(int qualityId)
{
return Queryable.Single(q => q.QualityId == qualityId);
}
}
}

View File

@ -0,0 +1,73 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NLog;
using NzbDrone.Core.Lifecycle;
namespace NzbDrone.Core.Qualities
{
public interface IQualitySizeService
{
void Update(QualitySize qualitySize);
void UpdateAll(List<QualitySize> qualitySizes);
List<QualitySize> All();
QualitySize Get(int qualityId);
}
public class QualitySizeService : IQualitySizeService, IInitializable
{
private readonly IQualitySizeRepository _qualitySizeRepository;
private readonly Logger _logger;
public QualitySizeService(IQualitySizeRepository qualitySizeRepository, Logger logger)
{
_qualitySizeRepository = qualitySizeRepository;
_logger = logger;
}
public virtual void Update(QualitySize qualitySize)
{
_qualitySizeRepository.Update(qualitySize);
}
public virtual void UpdateAll(List<QualitySize> qualitySizes)
{
_qualitySizeRepository.UpdateMany(qualitySizes);
}
public virtual List<QualitySize> All()
{
return _qualitySizeRepository.All().ToList();
}
public virtual QualitySize Get(int qualityId)
{
return _qualitySizeRepository.GetByQualityId(qualityId);
}
public void Init()
{
var inDb = All();
_logger.Debug("Setting up default quality sizes");
foreach (var quality in Quality.All())
{
//Skip UNKNOWN
if (quality.Id == 0) continue;
var db = inDb.SingleOrDefault(s => s.QualityId == quality.Id);
if(db == null)
_qualitySizeRepository.Insert(new QualitySize
{
QualityId = quality.Id,
Name = quality.Name,
MinSize = 0,
MaxSize = 100
});
}
}
}
}

View File

@ -1,49 +0,0 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using PetaPoco;
namespace NzbDrone.Core.Repository.Quality
{
[TableName("QualityProfiles")]
[PrimaryKey("QualityProfileId", autoIncrement = true)]
public class QualityProfile
{
public virtual int QualityProfileId { get; set; }
public string Name { get; set; }
[Ignore]
public List<QualityTypes> Allowed { get; set; }
[Ignore]
public string AllowedString { get; set; }
public QualityTypes Cutoff { get; set; }
[EditorBrowsable(EditorBrowsableState.Never)]
public string SonicAllowed
{
get
{
string result = String.Empty;
if (Allowed == null) return result;
foreach (var q in Allowed)
{
result += q.Id + "|";
}
return result.Trim('|');
}
private set
{
var qualities = value.Split('|');
Allowed = new List<QualityTypes>(qualities.Length);
foreach (var quality in qualities.Where(q => !String.IsNullOrWhiteSpace(q)))
{
Allowed.Add(QualityTypes.FindById(Convert.ToInt32(quality)));
}
}
}
}
}

View File

@ -2,7 +2,6 @@
using System.Collections.Generic;
using System.ComponentModel;
using NzbDrone.Core.Model;
using NzbDrone.Core.Repository.Quality;
using PetaPoco;
namespace NzbDrone.Core.Repository.Search

View File

@ -2,7 +2,7 @@
using System.Collections.Generic;
using System.ComponentModel;
using NzbDrone.Core.Model;
using NzbDrone.Core.Repository.Quality;
using NzbDrone.Core.Qualities;
using PetaPoco;
namespace NzbDrone.Core.Repository.Search
@ -19,7 +19,7 @@ public class SearchHistoryItem
public string NzbInfoUrl { get; set; }
public bool Success { get; set; }
public ReportRejectionType SearchError { get; set; }
public Quality.QualityTypes Quality { get; set; }
public Quality Quality { get; set; }
public bool Proper { get; set; }
public int Age { get; set; }
public LanguageType Language { get; set; }

View File

@ -1,6 +1,6 @@
using System.Linq;
using System;
using NzbDrone.Core.Repository.Quality;
using NzbDrone.Core.Qualities;
using PetaPoco;
namespace NzbDrone.Core.Tv
@ -28,7 +28,7 @@ public EpisodeFile(EpisodeFile source)
public int SeriesId { get; set; }
public int SeasonNumber { get; set; }
public string Path { get; set; }
public QualityTypes Quality { get; set; }
public Quality Quality { get; set; }
public bool Proper { get; set; }
public long Size { get; set; }
public DateTime DateAdded { get; set; }

View File

@ -1,21 +1,21 @@
using System.Linq;
using System;
using NzbDrone.Core.Repository.Quality;
using NzbDrone.Core.Qualities;
namespace NzbDrone.Core.Tv
{
public class QualityModel : IComparable<QualityModel>
{
public QualityTypes Quality { get; set; }
public Quality Quality { get; set; }
public Boolean Proper { get; set; }
public QualityModel():this(QualityTypes.Unknown, false)
public QualityModel():this(Quality.Unknown, false)
{
}
public QualityModel(QualityTypes quality, Boolean proper)
public QualityModel(Quality quality, Boolean proper)
{
Quality = quality;
Proper = proper;

View File

@ -2,7 +2,7 @@
using System;
using NzbDrone.Core.Datastore;
using NzbDrone.Core.Model;
using NzbDrone.Core.Repository.Quality;
using NzbDrone.Core.Qualities;
using PetaPoco;
namespace NzbDrone.Core.Tv

Binary file not shown.