mirror of
https://github.com/Readarr/Readarr.git
synced 2026-04-25 22:36:59 -04:00
New: Readarr 0.1
This commit is contained in:
@@ -57,7 +57,7 @@ namespace NzbDrone.Core.Test.NotificationTests
|
||||
TestLogger.Info("OnAlbumDownload was called");
|
||||
}
|
||||
|
||||
public override void OnRename(Artist artist)
|
||||
public override void OnRename(Author artist)
|
||||
{
|
||||
TestLogger.Info("OnRename was called");
|
||||
}
|
||||
|
||||
@@ -14,14 +14,14 @@ namespace NzbDrone.Core.Test.NotificationTests
|
||||
[TestFixture]
|
||||
public class SynologyIndexerFixture : CoreTest<SynologyIndexer>
|
||||
{
|
||||
private Artist _artist;
|
||||
private Author _artist;
|
||||
private AlbumDownloadMessage _upgrade;
|
||||
private string _rootPath = @"C:\Test\".AsOsAgnostic();
|
||||
|
||||
[SetUp]
|
||||
public void SetUp()
|
||||
{
|
||||
_artist = new Artist()
|
||||
_artist = new Author()
|
||||
{
|
||||
Path = _rootPath,
|
||||
};
|
||||
@@ -30,21 +30,21 @@ namespace NzbDrone.Core.Test.NotificationTests
|
||||
{
|
||||
Artist = _artist,
|
||||
|
||||
TrackFiles = new List<TrackFile>
|
||||
TrackFiles = new List<BookFile>
|
||||
{
|
||||
new TrackFile
|
||||
new BookFile
|
||||
{
|
||||
Path = Path.Combine(_rootPath, "file1.S01E01E02.mkv")
|
||||
}
|
||||
},
|
||||
|
||||
OldFiles = new List<TrackFile>
|
||||
OldFiles = new List<BookFile>
|
||||
{
|
||||
new TrackFile
|
||||
new BookFile
|
||||
{
|
||||
Path = Path.Combine(_rootPath, "file1.S01E01.mkv")
|
||||
},
|
||||
new TrackFile
|
||||
new BookFile
|
||||
{
|
||||
Path = Path.Combine(_rootPath, "file1.S01E02.mkv")
|
||||
}
|
||||
|
||||
@@ -1,91 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using FizzWare.NBuilder;
|
||||
using FluentAssertions;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.Music;
|
||||
using NzbDrone.Core.Notifications.Xbmc;
|
||||
using NzbDrone.Core.Notifications.Xbmc.Model;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
|
||||
namespace NzbDrone.Core.Test.NotificationTests.Xbmc
|
||||
{
|
||||
[TestFixture]
|
||||
public class GetArtistPathFixture : CoreTest<XbmcService>
|
||||
{
|
||||
private const string MB_ID = "9f4e41c3-2648-428e-b8c7-dc10465b49ac";
|
||||
private XbmcSettings _settings;
|
||||
private Music.Artist _artist;
|
||||
private List<KodiArtist> _xbmcArtist;
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
_settings = Builder<XbmcSettings>.CreateNew()
|
||||
.Build();
|
||||
|
||||
_xbmcArtist = Builder<KodiArtist>.CreateListOfSize(3)
|
||||
.All()
|
||||
.With(s => s.MusicbrainzArtistId = new List<string> { "0" })
|
||||
.TheFirst(1)
|
||||
.With(s => s.MusicbrainzArtistId = new List<string> { MB_ID.ToString() })
|
||||
.Build()
|
||||
.ToList();
|
||||
|
||||
Mocker.GetMock<IXbmcJsonApiProxy>()
|
||||
.Setup(s => s.GetArtist(_settings))
|
||||
.Returns(_xbmcArtist);
|
||||
}
|
||||
|
||||
private void GivenMatchingMusicbrainzId()
|
||||
{
|
||||
_artist = new Artist
|
||||
{
|
||||
ForeignArtistId = MB_ID,
|
||||
Name = "Artist"
|
||||
};
|
||||
}
|
||||
|
||||
private void GivenMatchingTitle()
|
||||
{
|
||||
_artist = new Artist
|
||||
{
|
||||
ForeignArtistId = "1000",
|
||||
Name = _xbmcArtist.First().Label
|
||||
};
|
||||
}
|
||||
|
||||
private void GivenMatchingArtist()
|
||||
{
|
||||
_artist = new Artist
|
||||
{
|
||||
ForeignArtistId = "1000",
|
||||
Name = "Does not exist"
|
||||
};
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_null_when_artist_is_not_found()
|
||||
{
|
||||
GivenMatchingArtist();
|
||||
|
||||
Subject.GetArtistPath(_settings, _artist).Should().BeNull();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_path_when_musicbrainzId_matches()
|
||||
{
|
||||
GivenMatchingMusicbrainzId();
|
||||
|
||||
Subject.GetArtistPath(_settings, _artist).Should().Be(_xbmcArtist.First().File);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_path_when_title_matches()
|
||||
{
|
||||
GivenMatchingTitle();
|
||||
|
||||
Subject.GetArtistPath(_settings, _artist).Should().Be(_xbmcArtist.First().File);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,71 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using FizzWare.NBuilder;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.MediaFiles;
|
||||
using NzbDrone.Core.Music;
|
||||
using NzbDrone.Core.Notifications;
|
||||
using NzbDrone.Core.Notifications.Xbmc;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
|
||||
namespace NzbDrone.Core.Test.NotificationTests.Xbmc
|
||||
{
|
||||
[TestFixture]
|
||||
public class OnReleaseImportFixture : CoreTest<Notifications.Xbmc.Xbmc>
|
||||
{
|
||||
private AlbumDownloadMessage _albumDownloadMessage;
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
var artist = Builder<Artist>.CreateNew()
|
||||
.Build();
|
||||
|
||||
var trackFile = Builder<TrackFile>.CreateNew()
|
||||
.Build();
|
||||
|
||||
_albumDownloadMessage = Builder<AlbumDownloadMessage>.CreateNew()
|
||||
.With(d => d.Artist = artist)
|
||||
.With(d => d.TrackFiles = new List<TrackFile> { trackFile })
|
||||
.With(d => d.OldFiles = new List<TrackFile>())
|
||||
.Build();
|
||||
|
||||
Subject.Definition = new NotificationDefinition();
|
||||
Subject.Definition.Settings = new XbmcSettings
|
||||
{
|
||||
UpdateLibrary = true
|
||||
};
|
||||
}
|
||||
|
||||
private void GivenOldFiles()
|
||||
{
|
||||
_albumDownloadMessage.OldFiles = Builder<TrackFile>.CreateListOfSize(1)
|
||||
.Build()
|
||||
.ToList();
|
||||
|
||||
Subject.Definition.Settings = new XbmcSettings
|
||||
{
|
||||
UpdateLibrary = true,
|
||||
CleanLibrary = true
|
||||
};
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_not_clean_if_no_episode_was_replaced()
|
||||
{
|
||||
Subject.OnReleaseImport(_albumDownloadMessage);
|
||||
|
||||
Mocker.GetMock<IXbmcService>().Verify(v => v.Clean(It.IsAny<XbmcSettings>()), Times.Never());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_clean_if_episode_was_replaced()
|
||||
{
|
||||
GivenOldFiles();
|
||||
Subject.OnReleaseImport(_albumDownloadMessage);
|
||||
|
||||
Mocker.GetMock<IXbmcService>().Verify(v => v.Clean(It.IsAny<XbmcSettings>()), Times.Once());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,70 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using FizzWare.NBuilder;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.Music;
|
||||
using NzbDrone.Core.Notifications.Xbmc;
|
||||
using NzbDrone.Core.Notifications.Xbmc.Model;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
|
||||
namespace NzbDrone.Core.Test.NotificationTests.Xbmc
|
||||
{
|
||||
[TestFixture]
|
||||
public class UpdateFixture : CoreTest<XbmcService>
|
||||
{
|
||||
private const string MB_ID = "9f4e41c3-2648-428e-b8c7-dc10465b49ac";
|
||||
private XbmcSettings _settings;
|
||||
private List<KodiArtist> _xbmcArtist;
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
_settings = Builder<XbmcSettings>.CreateNew()
|
||||
.Build();
|
||||
|
||||
_xbmcArtist = Builder<KodiArtist>.CreateListOfSize(3)
|
||||
.TheFirst(1)
|
||||
.With(s => s.MusicbrainzArtistId = new List<string> { MB_ID.ToString() })
|
||||
.TheNext(2)
|
||||
.With(s => s.MusicbrainzArtistId = new List<string>())
|
||||
.Build()
|
||||
.ToList();
|
||||
|
||||
Mocker.GetMock<IXbmcJsonApiProxy>()
|
||||
.Setup(s => s.GetArtist(_settings))
|
||||
.Returns(_xbmcArtist);
|
||||
|
||||
Mocker.GetMock<IXbmcJsonApiProxy>()
|
||||
.Setup(s => s.GetActivePlayers(_settings))
|
||||
.Returns(new List<ActivePlayer>());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_update_using_artist_path()
|
||||
{
|
||||
var artist = Builder<Music.Artist>.CreateNew()
|
||||
.With(s => s.ForeignArtistId = MB_ID)
|
||||
.Build();
|
||||
|
||||
Subject.Update(_settings, artist);
|
||||
|
||||
Mocker.GetMock<IXbmcJsonApiProxy>()
|
||||
.Verify(v => v.UpdateLibrary(_settings, It.IsAny<string>()), Times.Once());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_update_all_paths_when_artist_path_not_found()
|
||||
{
|
||||
var fakeArtist = Builder<Artist>.CreateNew()
|
||||
.With(s => s.ForeignArtistId = "9f4e41c3-2648-428e-b8c7-dc10465b49ad")
|
||||
.With(s => s.Name = "Not Shawn Desman")
|
||||
.Build();
|
||||
|
||||
Subject.Update(_settings, fakeArtist);
|
||||
|
||||
Mocker.GetMock<IXbmcJsonApiProxy>()
|
||||
.Verify(v => v.UpdateLibrary(_settings, null), Times.Once());
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user