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

cleaned up handling of Unknown quality type.

This commit is contained in:
Keivan Beigi 2013-05-30 18:43:13 -07:00
parent 3c53e6009d
commit c1bbd0bd5d
5 changed files with 9 additions and 15 deletions

View File

@ -28,14 +28,14 @@ public static class ValueInjectorExtensions
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);
}
}
}

View File

@ -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 @@ public class QualityProfileResource : RestResource
public class QualityResource : RestResource
{
public Int32 Id { get; set; }
public Int32 Weight { get; set; }
public String Name { get; set; }
}

View File

@ -17,7 +17,7 @@ public void Init_should_add_all_sizes()
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 @@ public void Init_should_insert_any_missing_sizes()
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));
}
}
}

View File

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

View File

@ -45,18 +45,13 @@ public virtual QualitySize Get(int qualityId)
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))
{