Fixed: Renaming Files Command Doesn't Resolve

pull/3718/head
Qstick 5 years ago
parent fbc2566f70
commit 6705b59b23

@ -34,14 +34,14 @@ namespace NzbDrone.Core.Test.MediaFiles
.Returns(_movie);
}
private void GivenNoEpisodeFiles()
private void GivenNoMovieFiles()
{
Mocker.GetMock<IMediaFileService>()
.Setup(s => s.GetMovies(It.IsAny<IEnumerable<int>>()))
.Returns(new List<MovieFile>());
}
private void GivenEpisodeFiles()
private void GivenMovieFiles()
{
Mocker.GetMock<IMediaFileService>()
.Setup(s => s.GetMovies(It.IsAny<IEnumerable<int>>()))
@ -57,9 +57,9 @@ namespace NzbDrone.Core.Test.MediaFiles
[Test]
public void should_not_publish_event_if_no_files_to_rename()
{
GivenNoEpisodeFiles();
GivenNoMovieFiles();
Subject.Execute(new RenameMovieFilesCommand(_movie.Id, new List<int>{1}));
Subject.Execute(new RenameFilesCommand(_movie.Id, new List<int>{1}));
Mocker.GetMock<IEventAggregator>()
.Verify(v => v.PublishEvent(It.IsAny<MovieRenamedEvent>()), Times.Never());
@ -68,13 +68,13 @@ namespace NzbDrone.Core.Test.MediaFiles
[Test]
public void should_not_publish_event_if_no_files_are_renamed()
{
GivenEpisodeFiles();
GivenMovieFiles();
Mocker.GetMock<IMoveMovieFiles>()
.Setup(s => s.MoveMovieFile(It.IsAny<MovieFile>(), It.IsAny<Movie>()))
.Throws(new SameFilenameException("Same file name", "Filename"));
Subject.Execute(new RenameMovieFilesCommand(_movie.Id, new List<int> { 1 }));
Subject.Execute(new RenameFilesCommand(_movie.Id, new List<int> { 1 }));
Mocker.GetMock<IEventAggregator>()
.Verify(v => v.PublishEvent(It.IsAny<MovieRenamedEvent>()), Times.Never());
@ -83,10 +83,10 @@ namespace NzbDrone.Core.Test.MediaFiles
[Test]
public void should_publish_event_if_files_are_renamed()
{
GivenEpisodeFiles();
GivenMovieFiles();
GivenMovedFiles();
Subject.Execute(new RenameMovieFilesCommand(_movie.Id, new List<int> { 1 }));
Subject.Execute(new RenameFilesCommand(_movie.Id, new List<int> { 1 }));
Mocker.GetMock<IEventAggregator>()
.Verify(v => v.PublishEvent(It.IsAny<MovieRenamedEvent>()), Times.Once());
@ -95,24 +95,24 @@ namespace NzbDrone.Core.Test.MediaFiles
[Test]
public void should_update_moved_files()
{
GivenEpisodeFiles();
GivenMovieFiles();
GivenMovedFiles();
Subject.Execute(new RenameMovieFilesCommand(_movie.Id, new List<int> { 1 }));
Subject.Execute(new RenameFilesCommand(_movie.Id, new List<int> { 1 }));
Mocker.GetMock<IMediaFileService>()
.Verify(v => v.Update(It.IsAny<MovieFile>()), Times.Exactly(2));
}
[Test]
public void should_get_episodefiles_by_ids_only()
public void should_get_moviefiles_by_ids_only()
{
GivenEpisodeFiles();
GivenMovieFiles();
GivenMovedFiles();
var files = new List<int> { 1 };
Subject.Execute(new RenameMovieFilesCommand(_movie.Id, files));
Subject.Execute(new RenameFilesCommand(_movie.Id, files));
Mocker.GetMock<IMediaFileService>()
.Verify(v => v.GetMovies(files), Times.Once());

@ -1,26 +0,0 @@
using NzbDrone.Core.Messaging.Commands;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace NzbDrone.Core.MediaFiles.Commands
{
public class RenameMovieFilesCommand : Command
{
public int MovieId { get; set; }
public List<int> Files { get; set; }
public override bool SendUpdatesToClient => true;
public RenameMovieFilesCommand()
{
}
public RenameMovieFilesCommand(int movieId, List<int> files)
{
MovieId = movieId;
Files = files;
}
}
}

@ -25,7 +25,7 @@ namespace NzbDrone.Core.MediaFiles
}
public class RenameMovieFileService : IRenameMovieFileService,
IExecute<RenameMovieFilesCommand>,
IExecute<RenameFilesCommand>,
IExecute<RenameMovieCommand>,
IExecute<RenameMovieFolderCommand>
{
@ -181,7 +181,7 @@ namespace NzbDrone.Core.MediaFiles
}
}
public void Execute(RenameMovieFilesCommand message)
public void Execute(RenameFilesCommand message)
{
var movie = _movieService.GetMovie(message.MovieId);
var movieFiles = _mediaFileService.GetMovies(message.Files);

@ -850,7 +850,6 @@
<Compile Include="MediaFiles\Commands\CleanUpRecycleBinCommand.cs" />
<Compile Include="MediaFiles\Commands\DownloadedMovieScanCommand.cs" />
<Compile Include="MediaFiles\Commands\RenameMovieCommand.cs" />
<Compile Include="MediaFiles\Commands\RenameMovieFilesCommand.cs" />
<Compile Include="MediaFiles\Commands\RescanMovieCommand.cs" />
<Compile Include="MediaFiles\DownloadedMovieCommandService.cs" />
<Compile Include="MediaFiles\DownloadedMovieImportService.cs" />

Loading…
Cancel
Save