Improve error message when deleting a profile that is in use

This commit is contained in:
Qstick
2018-02-15 22:03:24 -05:00
parent e8771c9c78
commit 425a9045b8
9 changed files with 43 additions and 22 deletions
@@ -41,15 +41,20 @@ namespace NzbDrone.Core.Test.Profiles
[Test]
public void should_not_be_able_to_delete_profile_if_assigned_to_artist()
{
var profile = Builder<Profile>.CreateNew()
.With(p => p.Id = 2)
.Build();
var artistList = Builder<Artist>.CreateListOfSize(3)
.Random(1)
.With(c => c.ProfileId = 2)
.With(c => c.ProfileId = profile.Id)
.Build().ToList();
Mocker.GetMock<IArtistService>().Setup(c => c.GetAllArtists()).Returns(artistList);
Mocker.GetMock<IProfileRepository>().Setup(c => c.Get(profile.Id)).Returns(profile);
Assert.Throws<ProfileInUseException>(() => Subject.Delete(2));
Assert.Throws<ProfileInUseException>(() => Subject.Delete(profile.Id));
Mocker.GetMock<IProfileRepository>().Verify(c => c.Delete(It.IsAny<int>()), Times.Never());