mirror of
https://github.com/Readarr/Readarr.git
synced 2026-04-26 22:46:37 -04:00
New: Add/remove individual albums
This commit is contained in:
@@ -3,11 +3,12 @@ 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;
|
||||
using NzbDrone.Core.Profiles.Metadata;
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
|
||||
namespace NzbDrone.Core.Test.Profiles.Metadata
|
||||
{
|
||||
@@ -21,7 +22,7 @@ namespace NzbDrone.Core.Test.Profiles.Metadata
|
||||
Subject.Handle(new ApplicationStartedEvent());
|
||||
|
||||
Mocker.GetMock<IMetadataProfileRepository>()
|
||||
.Verify(v => v.Insert(It.IsAny<MetadataProfile>()), Times.Once());
|
||||
.Verify(v => v.Insert(It.IsAny<MetadataProfile>()), Times.Exactly(2));
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -36,9 +37,72 @@ namespace NzbDrone.Core.Test.Profiles.Metadata
|
||||
Subject.Handle(new ApplicationStartedEvent());
|
||||
|
||||
Mocker.GetMock<IMetadataProfileRepository>()
|
||||
.Verify(v => v.Insert(It.IsAny<MetadataProfile>()), Times.Never());
|
||||
.Verify(v => v.Insert(It.Is<MetadataProfile>(x => x.Name == "Standard")), Times.Never());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void init_should_add_none_profile_if_it_doesnt_exist()
|
||||
{
|
||||
Mocker.GetMock<IMetadataProfileRepository>()
|
||||
.Setup(s => s.All())
|
||||
.Returns(Builder<MetadataProfile>.CreateListOfSize(2).Build().ToList());
|
||||
|
||||
Subject.Handle(new ApplicationStartedEvent());
|
||||
|
||||
Mocker.GetMock<IMetadataProfileRepository>()
|
||||
.Verify(v => v.Insert(It.Is<MetadataProfile>(x => x.Name == "None")), Times.Once());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void init_should_move_existing_none_profile()
|
||||
{
|
||||
var profiles = Builder<MetadataProfile>.CreateListOfSize(2)
|
||||
.TheFirst(1)
|
||||
.With(x => x.Name = MetadataProfileService.NONE_PROFILE_NAME)
|
||||
.With(x => x.PrimaryAlbumTypes = new List<ProfilePrimaryAlbumTypeItem>
|
||||
{
|
||||
new ProfilePrimaryAlbumTypeItem
|
||||
{
|
||||
PrimaryAlbumType = PrimaryAlbumType.Album,
|
||||
Allowed = true
|
||||
}
|
||||
})
|
||||
.BuildList();
|
||||
|
||||
Mocker.GetMock<IMetadataProfileRepository>()
|
||||
.Setup(s => s.All())
|
||||
.Returns(profiles);
|
||||
|
||||
Subject.Handle(new ApplicationStartedEvent());
|
||||
|
||||
Mocker.GetMock<IMetadataProfileRepository>()
|
||||
.Verify(v => v.Update(It.Is<MetadataProfile>(x => x.Id == profiles.First().Id && x.Name == "None.1")), Times.Once());
|
||||
|
||||
Mocker.GetMock<IMetadataProfileRepository>()
|
||||
.Verify(v => v.Insert(It.Is<MetadataProfile>(x => x.Name == "None")), Times.Once());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_not_be_able_to_edit_none_profile()
|
||||
{
|
||||
var profile = Builder<MetadataProfile>.CreateNew()
|
||||
.With(p => p.Name = MetadataProfileService.NONE_PROFILE_NAME)
|
||||
.Build();
|
||||
|
||||
Assert.Throws<InvalidOperationException>(() => Subject.Update(profile));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_not_be_able_to_delete_none_profile()
|
||||
{
|
||||
var profile = Builder<MetadataProfile>.CreateNew()
|
||||
.With(p => p.Name = MetadataProfileService.NONE_PROFILE_NAME)
|
||||
.Build();
|
||||
|
||||
Mocker.GetMock<IMetadataProfileRepository>().Setup(c => c.Get(profile.Id)).Returns(profile);
|
||||
|
||||
Assert.Throws<MetadataProfileInUseException>(() => Subject.Delete(profile.Id));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_not_be_able_to_delete_profile_if_assigned_to_artist()
|
||||
@@ -94,10 +158,13 @@ namespace NzbDrone.Core.Test.Profiles.Metadata
|
||||
|
||||
}
|
||||
|
||||
|
||||
[Test]
|
||||
public void should_delete_profile_if_not_assigned_to_artist_or_import_list()
|
||||
{
|
||||
var profile = Builder<MetadataProfile>.CreateNew()
|
||||
.With(p => p.Id = 1)
|
||||
.Build();
|
||||
|
||||
var artistList = Builder<Artist>.CreateListOfSize(3)
|
||||
.All()
|
||||
.With(c => c.MetadataProfileId = 2)
|
||||
@@ -110,6 +177,7 @@ namespace NzbDrone.Core.Test.Profiles.Metadata
|
||||
|
||||
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);
|
||||
|
||||
Subject.Delete(1);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user