|
|
|
@ -2,6 +2,8 @@ using System.Linq;
|
|
|
|
|
using FizzWare.NBuilder;
|
|
|
|
|
using Moq;
|
|
|
|
|
using NUnit.Framework;
|
|
|
|
|
using NzbDrone.Core.ImportLists;
|
|
|
|
|
using NzbDrone.Core.ImportLists.HeadphonesImport;
|
|
|
|
|
using NzbDrone.Core.Lifecycle;
|
|
|
|
|
using NzbDrone.Core.Test.Framework;
|
|
|
|
|
using NzbDrone.Core.Music;
|
|
|
|
@ -50,8 +52,40 @@ namespace NzbDrone.Core.Test.Profiles.Metadata
|
|
|
|
|
.With(c => c.MetadataProfileId = profile.Id)
|
|
|
|
|
.Build().ToList();
|
|
|
|
|
|
|
|
|
|
var importLists = Builder<ImportListDefinition>.CreateListOfSize(2)
|
|
|
|
|
.All()
|
|
|
|
|
.With(c => c.MetadataProfileId = 1)
|
|
|
|
|
.Build().ToList();
|
|
|
|
|
|
|
|
|
|
Mocker.GetMock<IArtistService>().Setup(c => c.GetAllArtists()).Returns(artistList);
|
|
|
|
|
Mocker.GetMock<IImportListFactory>().Setup(c => c.All()).Returns(importLists);
|
|
|
|
|
Mocker.GetMock<IMetadataProfileRepository>().Setup(c => c.Get(profile.Id)).Returns(profile);
|
|
|
|
|
|
|
|
|
|
Assert.Throws<MetadataProfileInUseException>(() => Subject.Delete(profile.Id));
|
|
|
|
|
|
|
|
|
|
Mocker.GetMock<IMetadataProfileRepository>().Verify(c => c.Delete(It.IsAny<int>()), Times.Never());
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void should_not_be_able_to_delete_profile_if_assigned_to_import_list()
|
|
|
|
|
{
|
|
|
|
|
var profile = Builder<MetadataProfile>.CreateNew()
|
|
|
|
|
.With(p => p.Id = 2)
|
|
|
|
|
.Build();
|
|
|
|
|
|
|
|
|
|
var artistList = Builder<Artist>.CreateListOfSize(3)
|
|
|
|
|
.All()
|
|
|
|
|
.With(c => c.MetadataProfileId = 1)
|
|
|
|
|
.Build().ToList();
|
|
|
|
|
|
|
|
|
|
var importLists = Builder<ImportListDefinition>.CreateListOfSize(2)
|
|
|
|
|
.Random(1)
|
|
|
|
|
.With(c => c.MetadataProfileId = profile.Id)
|
|
|
|
|
.Build().ToList();
|
|
|
|
|
|
|
|
|
|
Mocker.GetMock<IArtistService>().Setup(c => c.GetAllArtists()).Returns(artistList);
|
|
|
|
|
Mocker.GetMock<IImportListFactory>().Setup(c => c.All()).Returns(importLists);
|
|
|
|
|
Mocker.GetMock<IMetadataProfileRepository>().Setup(c => c.Get(profile.Id)).Returns(profile);
|
|
|
|
|
|
|
|
|
|
Assert.Throws<MetadataProfileInUseException>(() => Subject.Delete(profile.Id));
|
|
|
|
@ -62,15 +96,20 @@ namespace NzbDrone.Core.Test.Profiles.Metadata
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void should_delete_profile_if_not_assigned_to_series()
|
|
|
|
|
public void should_delete_profile_if_not_assigned_to_artist_or_import_list()
|
|
|
|
|
{
|
|
|
|
|
var artistList = Builder<Artist>.CreateListOfSize(3)
|
|
|
|
|
.All()
|
|
|
|
|
.With(c => c.MetadataProfileId = 2)
|
|
|
|
|
.Build().ToList();
|
|
|
|
|
|
|
|
|
|
var importLists = Builder<ImportListDefinition>.CreateListOfSize(2)
|
|
|
|
|
.All()
|
|
|
|
|
.With(c => c.MetadataProfileId = 2)
|
|
|
|
|
.Build().ToList();
|
|
|
|
|
|
|
|
|
|
Mocker.GetMock<IArtistService>().Setup(c => c.GetAllArtists()).Returns(artistList);
|
|
|
|
|
Mocker.GetMock<IImportListFactory>().Setup(c => c.All()).Returns(importLists);
|
|
|
|
|
|
|
|
|
|
Subject.Delete(1);
|
|
|
|
|
|
|
|
|
|