mirror of
https://github.com/Readarr/Readarr.git
synced 2026-04-23 22:25:09 -04:00
Fixed: Profile delete Unit Tests
This commit is contained in:
@@ -2,6 +2,7 @@ using System.Linq;
|
||||
using FizzWare.NBuilder;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.ImportLists;
|
||||
using NzbDrone.Core.Lifecycle;
|
||||
using NzbDrone.Core.Profiles.Qualities;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
@@ -50,8 +51,13 @@ namespace NzbDrone.Core.Test.Profiles
|
||||
.With(c => c.ProfileId = profile.Id)
|
||||
.Build().ToList();
|
||||
|
||||
var importLists = Builder<ImportListDefinition>.CreateListOfSize(2)
|
||||
.All()
|
||||
.With(c => c.ProfileId = 1)
|
||||
.Build().ToList();
|
||||
|
||||
Mocker.GetMock<IArtistService>().Setup(c => c.GetAllArtists()).Returns(artistList);
|
||||
Mocker.GetMock<IImportListFactory>().Setup(c => c.All()).Returns(importLists);
|
||||
Mocker.GetMock<IProfileRepository>().Setup(c => c.Get(profile.Id)).Returns(profile);
|
||||
|
||||
Assert.Throws<ProfileInUseException>(() => Subject.Delete(profile.Id));
|
||||
@@ -60,17 +66,48 @@ namespace NzbDrone.Core.Test.Profiles
|
||||
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_not_be_able_to_delete_profile_if_assigned_to_import_list()
|
||||
{
|
||||
var profile = Builder<Profile>.CreateNew()
|
||||
.With(p => p.Id = 2)
|
||||
.Build();
|
||||
|
||||
var artistList = Builder<Artist>.CreateListOfSize(3)
|
||||
.All()
|
||||
.With(c => c.ProfileId = 1)
|
||||
.Build().ToList();
|
||||
|
||||
var importLists = Builder<ImportListDefinition>.CreateListOfSize(2)
|
||||
.Random(1)
|
||||
.With(c => c.ProfileId = profile.Id)
|
||||
.Build().ToList();
|
||||
|
||||
Mocker.GetMock<IArtistService>().Setup(c => c.GetAllArtists()).Returns(artistList);
|
||||
Mocker.GetMock<IImportListFactory>().Setup(c => c.All()).Returns(importLists);
|
||||
Mocker.GetMock<IProfileRepository>().Setup(c => c.Get(profile.Id)).Returns(profile);
|
||||
|
||||
Assert.Throws<ProfileInUseException>(() => Subject.Delete(profile.Id));
|
||||
|
||||
Mocker.GetMock<IProfileRepository>().Verify(c => c.Delete(It.IsAny<int>()), Times.Never());
|
||||
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_delete_profile_if_not_assigned_to_artist()
|
||||
public void should_delete_profile_if_not_assigned_to_artist_or_import_list()
|
||||
{
|
||||
var artistList = Builder<Artist>.CreateListOfSize(3)
|
||||
.All()
|
||||
.With(c => c.ProfileId = 2)
|
||||
.Build().ToList();
|
||||
|
||||
var importLists = Builder<ImportListDefinition>.CreateListOfSize(2)
|
||||
.All()
|
||||
.With(c => c.ProfileId = 2)
|
||||
.Build().ToList();
|
||||
|
||||
Mocker.GetMock<IArtistService>().Setup(c => c.GetAllArtists()).Returns(artistList);
|
||||
Mocker.GetMock<IImportListFactory>().Setup(c => c.All()).Returns(importLists);
|
||||
|
||||
Subject.Delete(1);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user