mirror of https://github.com/lidarr/Lidarr
parent
7388e3fb66
commit
8c6f0d10e9
|
@ -26,7 +26,7 @@ namespace NzbDrone.Core.Test.Profiles
|
|||
|
||||
Subject.Handle(new ApplicationStartedEvent());
|
||||
|
||||
Mocker.GetMock<IProfileRepository>()
|
||||
Mocker.GetMock<IQualityProfileRepository>()
|
||||
.Verify(v => v.Insert(It.IsAny<QualityProfile>()), Times.Exactly(3));
|
||||
}
|
||||
|
||||
|
@ -36,13 +36,13 @@ namespace NzbDrone.Core.Test.Profiles
|
|||
// 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<IProfileRepository>()
|
||||
Mocker.GetMock<IQualityProfileRepository>()
|
||||
.Setup(s => s.All())
|
||||
.Returns(Builder<QualityProfile>.CreateListOfSize(2).Build().ToList());
|
||||
|
||||
Subject.Handle(new ApplicationStartedEvent());
|
||||
|
||||
Mocker.GetMock<IProfileRepository>()
|
||||
Mocker.GetMock<IQualityProfileRepository>()
|
||||
.Verify(v => v.Insert(It.IsAny<QualityProfile>()), Times.Never());
|
||||
}
|
||||
|
||||
|
@ -71,11 +71,11 @@ namespace NzbDrone.Core.Test.Profiles
|
|||
Mocker.GetMock<IArtistService>().Setup(c => c.GetAllArtists()).Returns(artistList);
|
||||
Mocker.GetMock<IImportListFactory>().Setup(c => c.All()).Returns(importLists);
|
||||
Mocker.GetMock<IRootFolderService>().Setup(c => c.All()).Returns(rootFolders);
|
||||
Mocker.GetMock<IProfileRepository>().Setup(c => c.Get(profile.Id)).Returns(profile);
|
||||
Mocker.GetMock<IQualityProfileRepository>().Setup(c => c.Get(profile.Id)).Returns(profile);
|
||||
|
||||
Assert.Throws<QualityProfileInUseException>(() => Subject.Delete(profile.Id));
|
||||
|
||||
Mocker.GetMock<IProfileRepository>().Verify(c => c.Delete(It.IsAny<int>()), Times.Never());
|
||||
Mocker.GetMock<IQualityProfileRepository>().Verify(c => c.Delete(It.IsAny<int>()), Times.Never());
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -103,11 +103,11 @@ namespace NzbDrone.Core.Test.Profiles
|
|||
Mocker.GetMock<IArtistService>().Setup(c => c.GetAllArtists()).Returns(artistList);
|
||||
Mocker.GetMock<IImportListFactory>().Setup(c => c.All()).Returns(importLists);
|
||||
Mocker.GetMock<IRootFolderService>().Setup(c => c.All()).Returns(rootFolders);
|
||||
Mocker.GetMock<IProfileRepository>().Setup(c => c.Get(profile.Id)).Returns(profile);
|
||||
Mocker.GetMock<IQualityProfileRepository>().Setup(c => c.Get(profile.Id)).Returns(profile);
|
||||
|
||||
Assert.Throws<QualityProfileInUseException>(() => Subject.Delete(profile.Id));
|
||||
|
||||
Mocker.GetMock<IProfileRepository>().Verify(c => c.Delete(It.IsAny<int>()), Times.Never());
|
||||
Mocker.GetMock<IQualityProfileRepository>().Verify(c => c.Delete(It.IsAny<int>()), Times.Never());
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -135,11 +135,11 @@ namespace NzbDrone.Core.Test.Profiles
|
|||
Mocker.GetMock<IArtistService>().Setup(c => c.GetAllArtists()).Returns(artistList);
|
||||
Mocker.GetMock<IImportListFactory>().Setup(c => c.All()).Returns(importLists);
|
||||
Mocker.GetMock<IRootFolderService>().Setup(c => c.All()).Returns(rootFolders);
|
||||
Mocker.GetMock<IProfileRepository>().Setup(c => c.Get(profile.Id)).Returns(profile);
|
||||
Mocker.GetMock<IQualityProfileRepository>().Setup(c => c.Get(profile.Id)).Returns(profile);
|
||||
|
||||
Assert.Throws<QualityProfileInUseException>(() => Subject.Delete(profile.Id));
|
||||
|
||||
Mocker.GetMock<IProfileRepository>().Verify(c => c.Delete(It.IsAny<int>()), Times.Never());
|
||||
Mocker.GetMock<IQualityProfileRepository>().Verify(c => c.Delete(It.IsAny<int>()), Times.Never());
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -166,7 +166,7 @@ namespace NzbDrone.Core.Test.Profiles
|
|||
|
||||
Subject.Delete(1);
|
||||
|
||||
Mocker.GetMock<IProfileRepository>().Verify(c => c.Delete(1), Times.Once());
|
||||
Mocker.GetMock<IQualityProfileRepository>().Verify(c => c.Delete(1), Times.Once());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,12 +6,12 @@ using NzbDrone.Core.Messaging.Events;
|
|||
|
||||
namespace NzbDrone.Core.Profiles.Qualities
|
||||
{
|
||||
public interface IProfileRepository : IBasicRepository<QualityProfile>
|
||||
public interface IQualityProfileRepository : IBasicRepository<QualityProfile>
|
||||
{
|
||||
bool Exists(int id);
|
||||
}
|
||||
|
||||
public class QualityProfileRepository : BasicRepository<QualityProfile>, IProfileRepository
|
||||
public class QualityProfileRepository : BasicRepository<QualityProfile>, IQualityProfileRepository
|
||||
{
|
||||
private readonly ICustomFormatService _customFormatService;
|
||||
|
||||
|
|
|
@ -29,21 +29,21 @@ namespace NzbDrone.Core.Profiles.Qualities
|
|||
IHandle<CustomFormatAddedEvent>,
|
||||
IHandle<CustomFormatDeletedEvent>
|
||||
{
|
||||
private readonly IProfileRepository _profileRepository;
|
||||
private readonly IQualityProfileRepository _qualityProfileRepository;
|
||||
private readonly IArtistService _artistService;
|
||||
private readonly IImportListFactory _importListFactory;
|
||||
private readonly ICustomFormatService _formatService;
|
||||
private readonly IRootFolderService _rootFolderService;
|
||||
private readonly Logger _logger;
|
||||
|
||||
public QualityProfileService(IProfileRepository profileRepository,
|
||||
public QualityProfileService(IQualityProfileRepository qualityProfileRepository,
|
||||
IArtistService artistService,
|
||||
IImportListFactory importListFactory,
|
||||
ICustomFormatService formatService,
|
||||
IRootFolderService rootFolderService,
|
||||
Logger logger)
|
||||
{
|
||||
_profileRepository = profileRepository;
|
||||
_qualityProfileRepository = qualityProfileRepository;
|
||||
_artistService = artistService;
|
||||
_importListFactory = importListFactory;
|
||||
_rootFolderService = rootFolderService;
|
||||
|
@ -53,12 +53,12 @@ namespace NzbDrone.Core.Profiles.Qualities
|
|||
|
||||
public QualityProfile Add(QualityProfile profile)
|
||||
{
|
||||
return _profileRepository.Insert(profile);
|
||||
return _qualityProfileRepository.Insert(profile);
|
||||
}
|
||||
|
||||
public void Update(QualityProfile profile)
|
||||
{
|
||||
_profileRepository.Update(profile);
|
||||
_qualityProfileRepository.Update(profile);
|
||||
}
|
||||
|
||||
public void Delete(int id)
|
||||
|
@ -67,26 +67,26 @@ namespace NzbDrone.Core.Profiles.Qualities
|
|||
_importListFactory.All().Any(c => c.ProfileId == id) ||
|
||||
_rootFolderService.All().Any(c => c.DefaultQualityProfileId == id))
|
||||
{
|
||||
var profile = _profileRepository.Get(id);
|
||||
var profile = _qualityProfileRepository.Get(id);
|
||||
throw new QualityProfileInUseException(profile.Name);
|
||||
}
|
||||
|
||||
_profileRepository.Delete(id);
|
||||
_qualityProfileRepository.Delete(id);
|
||||
}
|
||||
|
||||
public List<QualityProfile> All()
|
||||
{
|
||||
return _profileRepository.All().ToList();
|
||||
return _qualityProfileRepository.All().ToList();
|
||||
}
|
||||
|
||||
public QualityProfile Get(int id)
|
||||
{
|
||||
return _profileRepository.Get(id);
|
||||
return _qualityProfileRepository.Get(id);
|
||||
}
|
||||
|
||||
public bool Exists(int id)
|
||||
{
|
||||
return _profileRepository.Exists(id);
|
||||
return _qualityProfileRepository.Exists(id);
|
||||
}
|
||||
|
||||
public void Handle(ApplicationStartedEvent message)
|
||||
|
|
|
@ -11,7 +11,7 @@ namespace NzbDrone.Integration.Test.ApiTests
|
|||
{
|
||||
private void GivenExistingArtist()
|
||||
{
|
||||
WaitForCompletion(() => Profiles.All().Count > 0);
|
||||
WaitForCompletion(() => QualityProfiles.All().Count > 0);
|
||||
|
||||
foreach (var name in new[] { "Alien Ant Farm", "Kiss" })
|
||||
{
|
||||
|
|
|
@ -28,7 +28,7 @@ namespace NzbDrone.Integration.Test.ApiTests.WantedTests
|
|||
[Order(1)]
|
||||
public void cutoff_should_have_monitored_items()
|
||||
{
|
||||
EnsureProfileCutoff(1, "Lossless", true);
|
||||
EnsureQualityProfileCutoff(1, "Lossless", true);
|
||||
var artist = EnsureArtist("8ac6cc32-8ddf-43b1-9ac4-4b04f9053176", "Alien Ant Farm", true);
|
||||
EnsureTrackFile(artist, 1, 1, 1, Quality.MP3_192);
|
||||
|
||||
|
@ -41,7 +41,7 @@ namespace NzbDrone.Integration.Test.ApiTests.WantedTests
|
|||
[Order(1)]
|
||||
public void cutoff_should_not_have_unmonitored_items()
|
||||
{
|
||||
EnsureProfileCutoff(1, "Lossless", true);
|
||||
EnsureQualityProfileCutoff(1, "Lossless", true);
|
||||
var artist = EnsureArtist("8ac6cc32-8ddf-43b1-9ac4-4b04f9053176", "Alien Ant Farm", false);
|
||||
EnsureTrackFile(artist, 1, 1, 1, Quality.MP3_192);
|
||||
|
||||
|
@ -54,7 +54,7 @@ namespace NzbDrone.Integration.Test.ApiTests.WantedTests
|
|||
[Order(1)]
|
||||
public void cutoff_should_have_artist()
|
||||
{
|
||||
EnsureProfileCutoff(1, "Lossless", true);
|
||||
EnsureQualityProfileCutoff(1, "Lossless", true);
|
||||
var artist = EnsureArtist("8ac6cc32-8ddf-43b1-9ac4-4b04f9053176", "Alien Ant Farm", true);
|
||||
EnsureTrackFile(artist, 1, 1, 1, Quality.MP3_192);
|
||||
|
||||
|
@ -68,7 +68,7 @@ namespace NzbDrone.Integration.Test.ApiTests.WantedTests
|
|||
[Order(2)]
|
||||
public void cutoff_should_have_unmonitored_items()
|
||||
{
|
||||
EnsureProfileCutoff(1, "Lossless", true);
|
||||
EnsureQualityProfileCutoff(1, "Lossless", true);
|
||||
var artist = EnsureArtist("8ac6cc32-8ddf-43b1-9ac4-4b04f9053176", "Alien Ant Farm", false);
|
||||
EnsureTrackFile(artist, 1, 1, 1, Quality.MP3_192);
|
||||
|
||||
|
|
|
@ -49,7 +49,7 @@ namespace NzbDrone.Integration.Test
|
|||
public LogsClient Logs;
|
||||
public ClientBase<NamingConfigResource> NamingConfig;
|
||||
public NotificationClient Notifications;
|
||||
public ClientBase<QualityProfileResource> Profiles;
|
||||
public ClientBase<QualityProfileResource> QualityProfiles;
|
||||
public ReleaseClient Releases;
|
||||
public ReleasePushClient ReleasePush;
|
||||
public ClientBase<RootFolderResource> RootFolders;
|
||||
|
@ -115,7 +115,7 @@ namespace NzbDrone.Integration.Test
|
|||
Logs = new LogsClient(RestClient, ApiKey);
|
||||
NamingConfig = new ClientBase<NamingConfigResource>(RestClient, ApiKey, "config/naming");
|
||||
Notifications = new NotificationClient(RestClient, ApiKey);
|
||||
Profiles = new ClientBase<QualityProfileResource>(RestClient, ApiKey);
|
||||
QualityProfiles = new ClientBase<QualityProfileResource>(RestClient, ApiKey);
|
||||
Releases = new ReleaseClient(RestClient, ApiKey);
|
||||
ReleasePush = new ReleasePushClient(RestClient, ApiKey);
|
||||
RootFolders = new ClientBase<RootFolderResource>(RestClient, ApiKey);
|
||||
|
@ -331,10 +331,10 @@ namespace NzbDrone.Integration.Test
|
|||
}
|
||||
}
|
||||
|
||||
public QualityProfileResource EnsureProfileCutoff(int profileId, string cutoff, bool upgradeAllowed)
|
||||
public QualityProfileResource EnsureQualityProfileCutoff(int profileId, string cutoff, bool upgradeAllowed)
|
||||
{
|
||||
var needsUpdate = false;
|
||||
var profile = Profiles.Get(profileId);
|
||||
var profile = QualityProfiles.Get(profileId);
|
||||
var cutoffItem = profile.Items.First(x => x.Name == cutoff);
|
||||
|
||||
if (profile.Cutoff != cutoffItem.Id)
|
||||
|
@ -351,7 +351,7 @@ namespace NzbDrone.Integration.Test
|
|||
|
||||
if (needsUpdate)
|
||||
{
|
||||
profile = Profiles.Put(profile);
|
||||
profile = QualityProfiles.Put(profile);
|
||||
}
|
||||
|
||||
return profile;
|
||||
|
|
Loading…
Reference in New Issue