cleaned up handling of Unknown quality type.

pull/3113/head
Keivan Beigi 12 years ago
parent 3c53e6009d
commit c1bbd0bd5d

@ -28,14 +28,14 @@ namespace NzbDrone.Api.Mapping
foreach (var sourceItem in (IEnumerable)source) foreach (var sourceItem in (IEnumerable)source)
{ {
var e = Activator.CreateInstance(listSubType).InjectFrom(sourceItem); var e = Activator.CreateInstance(listSubType).InjectFrom<CloneInjection>(sourceItem);
addMethod.Invoke(result, new[] { e }); addMethod.Invoke(result, new[] { e });
} }
return result; return result;
} }
return (TTarget)new TTarget().InjectFrom(source); return (TTarget)new TTarget().InjectFrom<CloneInjection>(source);
} }
} }
} }

@ -6,7 +6,6 @@ namespace NzbDrone.Api.Qualities
{ {
public class QualityProfileResource : RestResource public class QualityProfileResource : RestResource
{ {
public Int32 Id { get; set; }
public String Name { get; set; } public String Name { get; set; }
public QualityResource Cutoff { get; set; } public QualityResource Cutoff { get; set; }
public List<QualityResource> Qualities { get; set; } public List<QualityResource> Qualities { get; set; }
@ -15,7 +14,6 @@ namespace NzbDrone.Api.Qualities
public class QualityResource : RestResource public class QualityResource : RestResource
{ {
public Int32 Id { get; set; }
public Int32 Weight { get; set; } public Int32 Weight { get; set; }
public String Name { get; set; } public String Name { get; set; }
} }

@ -8,16 +8,16 @@ using NzbDrone.Core.Test.Framework;
namespace NzbDrone.Core.Test.Qualities namespace NzbDrone.Core.Test.Qualities
{ {
[TestFixture] [TestFixture]
public class QualitySizeServiceFixture : CoreTest<QualitySizeService> public class QualitySizeServiceFixture : CoreTest<QualitySizeService>
{ {
[Test] [Test]
public void Init_should_add_all_sizes() public void Init_should_add_all_sizes()
{ {
Subject.Handle(new ApplicationStartedEvent()); Subject.Handle(new ApplicationStartedEvent());
Mocker.GetMock<IQualitySizeRepository>() Mocker.GetMock<IQualitySizeRepository>()
.Verify(v => v.Insert(It.IsAny<QualitySize>()), Times.Exactly(Quality.All().Count - 1)); .Verify(v => v.Insert(It.IsAny<QualitySize>()), Times.Exactly(Quality.All().Count));
} }
[Test] [Test]
@ -33,7 +33,7 @@ namespace NzbDrone.Core.Test.Qualities
Subject.Handle(new ApplicationStartedEvent()); Subject.Handle(new ApplicationStartedEvent());
Mocker.GetMock<IQualitySizeRepository>() Mocker.GetMock<IQualitySizeRepository>()
.Verify(v => v.Insert(It.IsAny<QualitySize>()), Times.Exactly(Quality.All().Count - 2)); .Verify(v => v.Insert(It.IsAny<QualitySize>()), Times.Exactly(Quality.All().Count - 1));
} }
} }
} }

@ -152,7 +152,6 @@ namespace NzbDrone.Core.Qualities
{ {
return new List<Quality> return new List<Quality>
{ {
Unknown,
SDTV, SDTV,
WEBDL480p, WEBDL480p,
DVD, DVD,
@ -168,6 +167,8 @@ namespace NzbDrone.Core.Qualities
public static Quality FindById(int id) public static Quality FindById(int id)
{ {
if (id == 0) return Unknown;
var quality = All().SingleOrDefault(q => q.Id == id); var quality = All().SingleOrDefault(q => q.Id == id);
if (quality == null) if (quality == null)

@ -45,18 +45,13 @@ namespace NzbDrone.Core.Qualities
return _qualitySizeRepository.GetByQualityId(qualityId); return _qualitySizeRepository.GetByQualityId(qualityId);
} }
public void Init()
{
}
public void Handle(ApplicationStartedEvent message) public void Handle(ApplicationStartedEvent message)
{ {
var existing = All(); var existing = All();
_logger.Debug("Setting up default quality sizes"); _logger.Debug("Setting up default quality sizes");
foreach (var quality in Quality.All().Where(q => q.Id > 0)) foreach (var quality in Quality.All())
{ {
if (!existing.Any(s => s.QualityId == quality.Id)) if (!existing.Any(s => s.QualityId == quality.Id))
{ {

Loading…
Cancel
Save