mirror of
https://github.com/Radarr/Radarr.git
synced 2024-10-05 15:47:20 +02:00
Fixed: MediaCoverService tests and stupidly forgetting to open the database connection for logging.
This commit is contained in:
parent
fed4a0aebe
commit
cd520b0341
@ -8,6 +8,7 @@
|
||||
using NzbDrone.Common.Disk;
|
||||
using NzbDrone.Common.EnvironmentInfo;
|
||||
using NzbDrone.Core.MediaCover;
|
||||
using NzbDrone.Core.Messaging.Commands;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Core.Movies;
|
||||
using NzbDrone.Core.Movies.Events;
|
||||
@ -28,6 +29,18 @@ public void Setup()
|
||||
.With(v => v.Id = 2)
|
||||
.With(v => v.Images = new List<MediaCover.MediaCover> { new MediaCover.MediaCover(MediaCoverTypes.Poster, "") })
|
||||
.Build();
|
||||
|
||||
Mocker.GetMock<IMovieService>().Setup(m => m.GetMovie(It.Is<int>(id => id == _movie.Id))).Returns(_movie);
|
||||
}
|
||||
|
||||
private void ExecuteAndVerifyCommand(Movie movie)
|
||||
{
|
||||
Subject.HandleAsync(new MovieUpdatedEvent(movie));
|
||||
|
||||
Mocker.GetMock<IManageCommandQueue>()
|
||||
.Verify(v => v.Push(It.Is<EnsureMediaCoversCommand>(c => c.MovieId == movie.Id), It.IsAny<CommandPriority>(), It.IsAny<CommandTrigger>()), Times.Once());
|
||||
|
||||
Subject.Execute(new EnsureMediaCoversCommand(movie.Id));
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -76,7 +89,7 @@ public void should_resize_covers_if_main_downloaded()
|
||||
.Setup(v => v.FileExists(It.IsAny<string>()))
|
||||
.Returns(true);
|
||||
|
||||
Subject.HandleAsync(new MovieUpdatedEvent(_movie));
|
||||
ExecuteAndVerifyCommand(_movie);
|
||||
|
||||
Mocker.GetMock<IImageResizer>()
|
||||
.Verify(v => v.Resize(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<int>()), Times.Exactly(2));
|
||||
@ -93,7 +106,7 @@ public void should_resize_covers_if_missing()
|
||||
.Setup(v => v.FileExists(It.IsAny<string>()))
|
||||
.Returns(false);
|
||||
|
||||
Subject.HandleAsync(new MovieUpdatedEvent(_movie));
|
||||
ExecuteAndVerifyCommand(_movie);
|
||||
|
||||
Mocker.GetMock<IImageResizer>()
|
||||
.Verify(v => v.Resize(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<int>()), Times.Exactly(2));
|
||||
@ -114,7 +127,7 @@ public void should_not_resize_covers_if_exists()
|
||||
.Setup(v => v.GetFileSize(It.IsAny<string>()))
|
||||
.Returns(1000);
|
||||
|
||||
Subject.HandleAsync(new MovieUpdatedEvent(_movie));
|
||||
ExecuteAndVerifyCommand(_movie);
|
||||
|
||||
Mocker.GetMock<IImageResizer>()
|
||||
.Verify(v => v.Resize(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<int>()), Times.Never());
|
||||
@ -135,7 +148,7 @@ public void should_resize_covers_if_existing_is_empty()
|
||||
.Setup(v => v.GetFileSize(It.IsAny<string>()))
|
||||
.Returns(0);
|
||||
|
||||
Subject.HandleAsync(new MovieUpdatedEvent(_movie));
|
||||
ExecuteAndVerifyCommand(_movie);
|
||||
|
||||
Mocker.GetMock<IImageResizer>()
|
||||
.Verify(v => v.Resize(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<int>()), Times.Exactly(2));
|
||||
@ -156,7 +169,7 @@ public void should_log_error_if_resize_failed()
|
||||
.Setup(v => v.Resize(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<int>()))
|
||||
.Throws<ApplicationException>();
|
||||
|
||||
Subject.HandleAsync(new MovieUpdatedEvent(_movie));
|
||||
ExecuteAndVerifyCommand(_movie);
|
||||
|
||||
Mocker.GetMock<IImageResizer>()
|
||||
.Verify(v => v.Resize(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<int>()), Times.Exactly(2));
|
||||
|
@ -89,6 +89,7 @@ protected override void Write(LogEventInfo logEvent)
|
||||
SQLiteFactory.Instance.CreateConnection())
|
||||
{
|
||||
connection.ConnectionString = _connectionStringFactory.LogDbConnectionString;
|
||||
connection.Open();
|
||||
using (var sqlCommand = connection.CreateCommand())
|
||||
{
|
||||
sqlCommand.CommandText = INSERT_COMMAND;
|
||||
|
@ -200,6 +200,7 @@ public void Execute(EnsureMediaCoversCommand command)
|
||||
public void HandleAsync(MovieUpdatedEvent message)
|
||||
{
|
||||
//EnsureCovers(message.Movie);
|
||||
_logger.Info("Testing: {0}, {1}", _commandQueue, message.Movie.Id);
|
||||
_commandQueue.Push(new EnsureMediaCoversCommand(message.Movie.Id));
|
||||
//_eventAggregator.PublishEvent(new MediaCoversUpdatedEvent(message.Movie));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user