Method, Variable, Class Renames in Readarr.Core

Co-Authored-By: ta264 <ta264@users.noreply.github.com>
This commit is contained in:
Qstick
2020-05-12 22:48:46 -04:00
parent 56aedcc467
commit 8547af9fae
572 changed files with 6584 additions and 6597 deletions
@@ -3,14 +3,14 @@ using FizzWare.NBuilder;
using Moq;
using NUnit.Framework;
using NzbDrone.Common.Extensions;
using NzbDrone.Core.Books;
using NzbDrone.Core.Books.Commands;
using NzbDrone.Core.Books.Events;
using NzbDrone.Core.Exceptions;
using NzbDrone.Core.History;
using NzbDrone.Core.ImportLists.Exclusions;
using NzbDrone.Core.MediaFiles;
using NzbDrone.Core.MetadataSource;
using NzbDrone.Core.Music;
using NzbDrone.Core.Music.Commands;
using NzbDrone.Core.Music.Events;
using NzbDrone.Core.Profiles.Metadata;
using NzbDrone.Core.RootFolders;
using NzbDrone.Core.Test.Framework;
@@ -19,7 +19,7 @@ using NzbDrone.Test.Common;
namespace NzbDrone.Core.Test.MusicTests
{
[TestFixture]
public class RefreshArtistServiceFixture : CoreTest<RefreshArtistService>
public class RefreshArtistServiceFixture : CoreTest<RefreshAuthorService>
{
private Author _artist;
private Book _album1;
@@ -51,11 +51,11 @@ namespace NzbDrone.Core.Test.MusicTests
.With(a => a.Series = series)
.Build();
Mocker.GetMock<IArtistService>(MockBehavior.Strict)
.Setup(s => s.GetArtists(new List<int> { _artist.Id }))
Mocker.GetMock<IAuthorService>(MockBehavior.Strict)
.Setup(s => s.GetAuthors(new List<int> { _artist.Id }))
.Returns(new List<Author> { _artist });
Mocker.GetMock<IAlbumService>(MockBehavior.Strict)
Mocker.GetMock<IBookService>(MockBehavior.Strict)
.Setup(s => s.InsertMany(It.IsAny<List<Book>>()));
Mocker.GetMock<IMetadataProfileService>()
@@ -64,14 +64,14 @@ namespace NzbDrone.Core.Test.MusicTests
Mocker.GetMock<IProvideAuthorInfo>()
.Setup(s => s.GetAuthorInfo(It.IsAny<string>()))
.Callback(() => { throw new ArtistNotFoundException(_artist.ForeignAuthorId); });
.Callback(() => { throw new AuthorNotFoundException(_artist.ForeignAuthorId); });
Mocker.GetMock<IMediaFileService>()
.Setup(x => x.GetFilesByArtist(It.IsAny<int>()))
.Setup(x => x.GetFilesByAuthor(It.IsAny<int>()))
.Returns(new List<BookFile>());
Mocker.GetMock<IHistoryService>()
.Setup(x => x.GetByArtist(It.IsAny<int>(), It.IsAny<HistoryEventType?>()))
.Setup(x => x.GetByAuthor(It.IsAny<int>(), It.IsAny<HistoryEventType?>()))
.Returns(new List<History.History>());
Mocker.GetMock<IImportListExclusionService>()
@@ -93,21 +93,21 @@ namespace NzbDrone.Core.Test.MusicTests
private void GivenArtistFiles()
{
Mocker.GetMock<IMediaFileService>()
.Setup(x => x.GetFilesByArtist(It.IsAny<int>()))
.Setup(x => x.GetFilesByAuthor(It.IsAny<int>()))
.Returns(Builder<BookFile>.CreateListOfSize(1).BuildList());
}
private void GivenAlbumsForRefresh(List<Book> albums)
{
Mocker.GetMock<IAlbumService>(MockBehavior.Strict)
.Setup(s => s.GetAlbumsForRefresh(It.IsAny<int>(), It.IsAny<IEnumerable<string>>()))
Mocker.GetMock<IBookService>(MockBehavior.Strict)
.Setup(s => s.GetBooksForRefresh(It.IsAny<int>(), It.IsAny<IEnumerable<string>>()))
.Returns(albums);
}
private void AllowArtistUpdate()
{
Mocker.GetMock<IArtistService>(MockBehavior.Strict)
.Setup(x => x.UpdateArtist(It.IsAny<Author>()))
Mocker.GetMock<IAuthorService>(MockBehavior.Strict)
.Setup(x => x.UpdateAuthor(It.IsAny<Author>()))
.Returns((Author a) => a);
}
@@ -122,10 +122,10 @@ namespace NzbDrone.Core.Test.MusicTests
GivenAlbumsForRefresh(_albums);
AllowArtistUpdate();
Subject.Execute(new RefreshArtistCommand(_artist.Id));
Subject.Execute(new RefreshAuthorCommand(_artist.Id));
VerifyEventNotPublished<ArtistUpdatedEvent>();
VerifyEventPublished<ArtistRefreshCompleteEvent>();
VerifyEventNotPublished<AuthorUpdatedEvent>();
VerifyEventPublished<AuthorRefreshCompleteEvent>();
}
[Test]
@@ -143,25 +143,25 @@ namespace NzbDrone.Core.Test.MusicTests
GivenAlbumsForRefresh(new List<Book>());
AllowArtistUpdate();
Subject.Execute(new RefreshArtistCommand(_artist.Id));
Subject.Execute(new RefreshAuthorCommand(_artist.Id));
VerifyEventPublished<ArtistUpdatedEvent>();
VerifyEventPublished<ArtistRefreshCompleteEvent>();
VerifyEventPublished<AuthorUpdatedEvent>();
VerifyEventPublished<AuthorRefreshCompleteEvent>();
}
[Test]
public void should_log_error_and_delete_if_musicbrainz_id_not_found_and_artist_has_no_files()
{
Mocker.GetMock<IArtistService>()
.Setup(x => x.DeleteArtist(It.IsAny<int>(), It.IsAny<bool>(), It.IsAny<bool>()));
Mocker.GetMock<IAuthorService>()
.Setup(x => x.DeleteAuthor(It.IsAny<int>(), It.IsAny<bool>(), It.IsAny<bool>()));
Subject.Execute(new RefreshArtistCommand(_artist.Id));
Subject.Execute(new RefreshAuthorCommand(_artist.Id));
Mocker.GetMock<IArtistService>()
.Verify(v => v.UpdateArtist(It.IsAny<Author>()), Times.Never());
Mocker.GetMock<IAuthorService>()
.Verify(v => v.UpdateAuthor(It.IsAny<Author>()), Times.Never());
Mocker.GetMock<IArtistService>()
.Verify(v => v.DeleteArtist(It.IsAny<int>(), It.IsAny<bool>(), It.IsAny<bool>()), Times.Once());
Mocker.GetMock<IAuthorService>()
.Verify(v => v.DeleteAuthor(It.IsAny<int>(), It.IsAny<bool>(), It.IsAny<bool>()), Times.Once());
ExceptionVerification.ExpectedErrors(1);
ExceptionVerification.ExpectedWarns(1);
@@ -173,13 +173,13 @@ namespace NzbDrone.Core.Test.MusicTests
GivenArtistFiles();
GivenAlbumsForRefresh(new List<Book>());
Subject.Execute(new RefreshArtistCommand(_artist.Id));
Subject.Execute(new RefreshAuthorCommand(_artist.Id));
Mocker.GetMock<IArtistService>()
.Verify(v => v.UpdateArtist(It.IsAny<Author>()), Times.Never());
Mocker.GetMock<IAuthorService>()
.Verify(v => v.UpdateAuthor(It.IsAny<Author>()), Times.Never());
Mocker.GetMock<IArtistService>()
.Verify(v => v.DeleteArtist(It.IsAny<int>(), It.IsAny<bool>(), It.IsAny<bool>()), Times.Never());
Mocker.GetMock<IAuthorService>()
.Verify(v => v.DeleteAuthor(It.IsAny<int>(), It.IsAny<bool>(), It.IsAny<bool>()), Times.Never());
ExceptionVerification.ExpectedErrors(2);
}
@@ -197,31 +197,31 @@ namespace NzbDrone.Core.Test.MusicTests
var seq = new MockSequence();
Mocker.GetMock<IArtistService>(MockBehavior.Strict)
Mocker.GetMock<IAuthorService>(MockBehavior.Strict)
.Setup(x => x.FindById(newArtistInfo.ForeignAuthorId))
.Returns(default(Author));
// Make sure that the artist is updated before we refresh the albums
Mocker.GetMock<IArtistService>(MockBehavior.Strict)
Mocker.GetMock<IAuthorService>(MockBehavior.Strict)
.InSequence(seq)
.Setup(x => x.UpdateArtist(It.IsAny<Author>()))
.Setup(x => x.UpdateAuthor(It.IsAny<Author>()))
.Returns((Author a) => a);
Mocker.GetMock<IAlbumService>(MockBehavior.Strict)
Mocker.GetMock<IBookService>(MockBehavior.Strict)
.InSequence(seq)
.Setup(x => x.GetAlbumsForRefresh(It.IsAny<int>(), It.IsAny<IEnumerable<string>>()))
.Setup(x => x.GetBooksForRefresh(It.IsAny<int>(), It.IsAny<IEnumerable<string>>()))
.Returns(new List<Book>());
// Update called twice for a move/merge
Mocker.GetMock<IArtistService>(MockBehavior.Strict)
Mocker.GetMock<IAuthorService>(MockBehavior.Strict)
.InSequence(seq)
.Setup(x => x.UpdateArtist(It.IsAny<Author>()))
.Setup(x => x.UpdateAuthor(It.IsAny<Author>()))
.Returns((Author a) => a);
Subject.Execute(new RefreshArtistCommand(_artist.Id));
Subject.Execute(new RefreshAuthorCommand(_artist.Id));
Mocker.GetMock<IArtistService>()
.Verify(v => v.UpdateArtist(It.Is<Author>(s => s.AuthorMetadataId == 100 && s.ForeignAuthorId == newArtistInfo.ForeignAuthorId)),
Mocker.GetMock<IAuthorService>()
.Verify(v => v.UpdateAuthor(It.Is<Author>(s => s.AuthorMetadataId == 100 && s.ForeignAuthorId == newArtistInfo.ForeignAuthorId)),
Times.Exactly(2));
}
@@ -236,7 +236,7 @@ namespace NzbDrone.Core.Test.MusicTests
clash.Metadata.Value.Id = 101;
clash.Metadata.Value.ForeignAuthorId = clash.Metadata.Value.ForeignAuthorId + 1;
Mocker.GetMock<IArtistService>(MockBehavior.Strict)
Mocker.GetMock<IAuthorService>(MockBehavior.Strict)
.Setup(x => x.FindById(clash.Metadata.Value.ForeignAuthorId))
.Returns(clash);
@@ -249,46 +249,46 @@ namespace NzbDrone.Core.Test.MusicTests
var seq = new MockSequence();
// Make sure that the artist is updated before we refresh the albums
Mocker.GetMock<IAlbumService>(MockBehavior.Strict)
Mocker.GetMock<IBookService>(MockBehavior.Strict)
.InSequence(seq)
.Setup(x => x.GetAlbumsByArtist(existing.Id))
.Setup(x => x.GetBooksByAuthor(existing.Id))
.Returns(_albums);
Mocker.GetMock<IAlbumService>(MockBehavior.Strict)
Mocker.GetMock<IBookService>(MockBehavior.Strict)
.InSequence(seq)
.Setup(x => x.UpdateMany(It.IsAny<List<Book>>()));
Mocker.GetMock<IArtistService>(MockBehavior.Strict)
Mocker.GetMock<IAuthorService>(MockBehavior.Strict)
.InSequence(seq)
.Setup(x => x.DeleteArtist(existing.Id, It.IsAny<bool>(), false));
.Setup(x => x.DeleteAuthor(existing.Id, It.IsAny<bool>(), false));
Mocker.GetMock<IArtistService>(MockBehavior.Strict)
Mocker.GetMock<IAuthorService>(MockBehavior.Strict)
.InSequence(seq)
.Setup(x => x.UpdateArtist(It.Is<Author>(a => a.Id == clash.Id)))
.Setup(x => x.UpdateAuthor(It.Is<Author>(a => a.Id == clash.Id)))
.Returns((Author a) => a);
Mocker.GetMock<IAlbumService>(MockBehavior.Strict)
Mocker.GetMock<IBookService>(MockBehavior.Strict)
.InSequence(seq)
.Setup(x => x.GetAlbumsForRefresh(clash.AuthorMetadataId, It.IsAny<IEnumerable<string>>()))
.Setup(x => x.GetBooksForRefresh(clash.AuthorMetadataId, It.IsAny<IEnumerable<string>>()))
.Returns(_albums);
// Update called twice for a move/merge
Mocker.GetMock<IArtistService>(MockBehavior.Strict)
Mocker.GetMock<IAuthorService>(MockBehavior.Strict)
.InSequence(seq)
.Setup(x => x.UpdateArtist(It.IsAny<Author>()))
.Setup(x => x.UpdateAuthor(It.IsAny<Author>()))
.Returns((Author a) => a);
Subject.Execute(new RefreshArtistCommand(_artist.Id));
Subject.Execute(new RefreshAuthorCommand(_artist.Id));
// the retained artist gets updated
Mocker.GetMock<IArtistService>()
.Verify(v => v.UpdateArtist(It.Is<Author>(s => s.Id == clash.Id)), Times.Exactly(2));
Mocker.GetMock<IAuthorService>()
.Verify(v => v.UpdateAuthor(It.Is<Author>(s => s.Id == clash.Id)), Times.Exactly(2));
// the old one gets removed
Mocker.GetMock<IArtistService>()
.Verify(v => v.DeleteArtist(existing.Id, false, false));
Mocker.GetMock<IAuthorService>()
.Verify(v => v.DeleteAuthor(existing.Id, false, false));
Mocker.GetMock<IAlbumService>()
Mocker.GetMock<IBookService>()
.Verify(v => v.UpdateMany(It.Is<List<Book>>(x => x.Count == _albums.Count)));
ExceptionVerification.ExpectedWarns(1);