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

Fixed: Check that Quality Profile is not in use before deleting it.

This commit is contained in:
Qstick 2017-08-06 06:10:17 -04:00 committed by Leonardo Galli
parent 17feedaf53
commit 4e9a931537
2 changed files with 11 additions and 11 deletions

View File

@ -1,4 +1,4 @@
using System.Linq;
using System.Linq;
using FizzWare.NBuilder;
using Moq;
using NUnit.Framework;
@ -39,15 +39,15 @@ public void Init_should_skip_if_any_profiles_already_exist()
[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)
.With(c => c.ProfileId = 2)
.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));
@ -57,15 +57,15 @@ public void should_not_be_able_to_delete_profile_if_assigned_to_series()
[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()
.With(c => c.ProfileId = 2)
.Build().ToList();
Mocker.GetMock<ISeriesService>().Setup(c => c.GetAllSeries()).Returns(seriesList);
Mocker.GetMock<IMovieService>().Setup(c => c.GetAllMovies()).Returns(movieList);
Subject.Delete(1);

View File

@ -22,13 +22,13 @@ public interface IProfileService
public class ProfileService : IProfileService, IHandle<ApplicationStartedEvent>
{
private readonly IProfileRepository _profileRepository;
private readonly ISeriesService _seriesService;
private readonly IMovieService _movieService;
private readonly Logger _logger;
public ProfileService(IProfileRepository profileRepository, ISeriesService seriesService, Logger logger)
public ProfileService(IProfileRepository profileRepository, IMovieService movieService, Logger logger)
{
_profileRepository = profileRepository;
_seriesService = seriesService;
_movieService = movieService;
_logger = logger;
}
@ -44,7 +44,7 @@ public void Update(Profile profile)
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);
}