mirror of https://github.com/Radarr/Radarr
parent
10fc0b071f
commit
5e7f0f9d78
|
@ -0,0 +1,51 @@
|
|||
using FizzWare.NBuilder;
|
||||
using FluentAssertions;
|
||||
using NUnit.Framework;
|
||||
using NUnit.Framework.Internal;
|
||||
using NzbDrone.Core.Organizer;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Core.Movies;
|
||||
|
||||
namespace NzbDrone.Core.Test.OrganizerTests.FileNameBuilderTests
|
||||
{
|
||||
[TestFixture]
|
||||
public class IdFixture : CoreTest<FileNameBuilder>
|
||||
{
|
||||
private Movie _movie;
|
||||
private NamingConfig _namingConfig;
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
_movie = Builder<Movie>
|
||||
.CreateNew()
|
||||
.With(s => s.Title = "Movie Title")
|
||||
.With(s => s.ImdbId = "tt12345")
|
||||
.With(s => s.TmdbId = 123456)
|
||||
.Build();
|
||||
|
||||
_namingConfig = NamingConfig.Default;
|
||||
|
||||
Mocker.GetMock<INamingConfigService>()
|
||||
.Setup(c => c.GetConfig()).Returns(_namingConfig);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_add_imdb_id()
|
||||
{
|
||||
_namingConfig.MovieFolderFormat = "{Movie Title} ({ImdbId})";
|
||||
|
||||
Subject.GetMovieFolder(_movie)
|
||||
.Should().Be($"Movie Title ({_movie.ImdbId})");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_add_tmdb_id()
|
||||
{
|
||||
_namingConfig.MovieFolderFormat = "{Movie Title} ({TmdbId})";
|
||||
|
||||
Subject.GetMovieFolder(_movie)
|
||||
.Should().Be($"Movie Title ({_movie.TmdbId})");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -91,7 +91,7 @@ namespace NzbDrone.Core.Organizer
|
|||
|
||||
AddMovieTokens(tokenHandlers, movie);
|
||||
AddReleaseDateTokens(tokenHandlers, movie.Year);
|
||||
AddImdbIdTokens(tokenHandlers, movie.ImdbId);
|
||||
AddIdTokens(tokenHandlers, movie);
|
||||
AddQualityTokens(tokenHandlers, movie, movieFile);
|
||||
AddMediaInfoTokens(tokenHandlers, movieFile);
|
||||
AddMovieFileTokens(tokenHandlers, movieFile);
|
||||
|
@ -140,7 +140,7 @@ namespace NzbDrone.Core.Organizer
|
|||
|
||||
AddMovieTokens(tokenHandlers, movie);
|
||||
AddReleaseDateTokens(tokenHandlers, movie.Year);
|
||||
AddImdbIdTokens(tokenHandlers, movie.ImdbId);
|
||||
AddIdTokens(tokenHandlers, movie);
|
||||
|
||||
if(movie.MovieFile != null)
|
||||
{
|
||||
|
@ -183,7 +183,7 @@ namespace NzbDrone.Core.Organizer
|
|||
|
||||
AddMovieTokens(tokenHandlers, movie);
|
||||
AddReleaseDateTokens(tokenHandlers, movie.Year);
|
||||
AddImdbIdTokens(tokenHandlers, movie.ImdbId);
|
||||
AddIdTokens(tokenHandlers, movie);
|
||||
|
||||
if (movie.MovieFile != null)
|
||||
{
|
||||
|
@ -276,9 +276,10 @@ namespace NzbDrone.Core.Organizer
|
|||
tokenHandlers["{Release Year}"] = m => string.Format("{0}", releaseYear.ToString()); //Do I need m.CustomFormat?
|
||||
}
|
||||
|
||||
private void AddImdbIdTokens(Dictionary<string, Func<TokenMatch, string>> tokenHandlers, string imdbId)
|
||||
private void AddIdTokens(Dictionary<string, Func<TokenMatch, string>> tokenHandlers, Movie movie)
|
||||
{
|
||||
tokenHandlers["{IMDb Id}"] = m => $"{imdbId}";
|
||||
tokenHandlers["{ImdbId}"] = m => movie.ImdbId ?? string.Empty;
|
||||
tokenHandlers["{TmdbId}"] = m => movie.TmdbId.ToString();
|
||||
}
|
||||
|
||||
private void AddMovieFileTokens(Dictionary<string, Func<TokenMatch, string>> tokenHandlers, MovieFile movieFile)
|
||||
|
|
|
@ -67,6 +67,7 @@ namespace NzbDrone.Core.Organizer
|
|||
Title = "The Movie: Title",
|
||||
Year = 2010,
|
||||
ImdbId = "tt0066921",
|
||||
TmdbId = 345691,
|
||||
MovieFile = _movieFile,
|
||||
MovieFileId = 1,
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue