cleaned up handling of Unknown quality type.

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

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

@ -17,7 +17,7 @@ namespace NzbDrone.Core.Test.Qualities
Subject.Handle(new ApplicationStartedEvent());
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]
@ -33,7 +33,7 @@ namespace NzbDrone.Core.Test.Qualities
Subject.Handle(new ApplicationStartedEvent());
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>
{
Unknown,
SDTV,
WEBDL480p,
DVD,
@ -168,6 +167,8 @@ namespace NzbDrone.Core.Qualities
public static Quality FindById(int id)
{
if (id == 0) return Unknown;
var quality = All().SingleOrDefault(q => q.Id == id);
if (quality == null)

@ -45,18 +45,13 @@ namespace NzbDrone.Core.Qualities
return _qualitySizeRepository.GetByQualityId(qualityId);
}
public void Init()
{
}
public void Handle(ApplicationStartedEvent message)
{
var existing = All();
_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))
{

Loading…
Cancel
Save