mirror of
https://github.com/lidarr/lidarr.git
synced 2025-08-23 14:55:20 -07:00
Fixed: Check that Quality Profile is not in use before deleting it.
This commit is contained in:
parent
17feedaf53
commit
4e9a931537
2 changed files with 11 additions and 11 deletions
|
@ -1,4 +1,4 @@
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using FizzWare.NBuilder;
|
using FizzWare.NBuilder;
|
||||||
using Moq;
|
using Moq;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
|
@ -39,15 +39,15 @@ namespace NzbDrone.Core.Test.Profiles
|
||||||
|
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void should_not_be_able_to_delete_profile_if_assigned_to_series()
|
public void should_not_be_able_to_delete_profile_if_assigned_to_movie()
|
||||||
{
|
{
|
||||||
var seriesList = Builder<Series>.CreateListOfSize(3)
|
var movieList = Builder<Movie>.CreateListOfSize(3)
|
||||||
.Random(1)
|
.Random(1)
|
||||||
.With(c => c.ProfileId = 2)
|
.With(c => c.ProfileId = 2)
|
||||||
.Build().ToList();
|
.Build().ToList();
|
||||||
|
|
||||||
|
|
||||||
Mocker.GetMock<ISeriesService>().Setup(c => c.GetAllSeries()).Returns(seriesList);
|
Mocker.GetMock<IMovieService>().Setup(c => c.GetAllMovies()).Returns(movieList);
|
||||||
|
|
||||||
Assert.Throws<ProfileInUseException>(() => Subject.Delete(2));
|
Assert.Throws<ProfileInUseException>(() => Subject.Delete(2));
|
||||||
|
|
||||||
|
@ -57,15 +57,15 @@ namespace NzbDrone.Core.Test.Profiles
|
||||||
|
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void should_delete_profile_if_not_assigned_to_series()
|
public void should_delete_profile_if_not_assigned_to_movie()
|
||||||
{
|
{
|
||||||
var seriesList = Builder<Series>.CreateListOfSize(3)
|
var movieList = Builder<Movie>.CreateListOfSize(3)
|
||||||
.All()
|
.All()
|
||||||
.With(c => c.ProfileId = 2)
|
.With(c => c.ProfileId = 2)
|
||||||
.Build().ToList();
|
.Build().ToList();
|
||||||
|
|
||||||
|
|
||||||
Mocker.GetMock<ISeriesService>().Setup(c => c.GetAllSeries()).Returns(seriesList);
|
Mocker.GetMock<IMovieService>().Setup(c => c.GetAllMovies()).Returns(movieList);
|
||||||
|
|
||||||
Subject.Delete(1);
|
Subject.Delete(1);
|
||||||
|
|
||||||
|
|
|
@ -22,13 +22,13 @@ namespace NzbDrone.Core.Profiles
|
||||||
public class ProfileService : IProfileService, IHandle<ApplicationStartedEvent>
|
public class ProfileService : IProfileService, IHandle<ApplicationStartedEvent>
|
||||||
{
|
{
|
||||||
private readonly IProfileRepository _profileRepository;
|
private readonly IProfileRepository _profileRepository;
|
||||||
private readonly ISeriesService _seriesService;
|
private readonly IMovieService _movieService;
|
||||||
private readonly Logger _logger;
|
private readonly Logger _logger;
|
||||||
|
|
||||||
public ProfileService(IProfileRepository profileRepository, ISeriesService seriesService, Logger logger)
|
public ProfileService(IProfileRepository profileRepository, IMovieService movieService, Logger logger)
|
||||||
{
|
{
|
||||||
_profileRepository = profileRepository;
|
_profileRepository = profileRepository;
|
||||||
_seriesService = seriesService;
|
_movieService = movieService;
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,7 +44,7 @@ namespace NzbDrone.Core.Profiles
|
||||||
|
|
||||||
public void Delete(int id)
|
public void Delete(int id)
|
||||||
{
|
{
|
||||||
if (_seriesService.GetAllSeries().Any(c => c.ProfileId == id))
|
if (_movieService.GetAllMovies().Any(c => c.ProfileId == id))
|
||||||
{
|
{
|
||||||
throw new ProfileInUseException(id);
|
throw new ProfileInUseException(id);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue