You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Lidarr/src/NzbDrone.Core.Test/NotificationTests/SynologyIndexerFixture.cs

105 lines
3.1 KiB

using System.Collections.Generic;
using System.IO;
using Moq;
using NUnit.Framework;
using NzbDrone.Core.MediaFiles;
using NzbDrone.Core.Music;
using NzbDrone.Core.Notifications;
using NzbDrone.Core.Notifications.Synology;
using NzbDrone.Core.Test.Framework;
using NzbDrone.Test.Common;
namespace NzbDrone.Core.Test.NotificationTests
{
[TestFixture]
public class SynologyIndexerFixture : CoreTest<SynologyIndexer>
{
private Artist _artist;
private AlbumDownloadMessage _upgrade;
private string _rootPath = @"C:\Test\".AsOsAgnostic();
[SetUp]
public void SetUp()
{
_artist = new Artist()
{
Path = _rootPath,
};
_upgrade = new AlbumDownloadMessage()
{
Artist = _artist,
TrackFiles = new List<TrackFile>
{
new TrackFile
{
Path = Path.Combine(_rootPath, "file1.S01E01E02.mkv")
}
},
OldFiles = new List<TrackFile>
{
new TrackFile
{
Path = Path.Combine(_rootPath, "file1.S01E01.mkv")
},
new TrackFile
{
Path = Path.Combine(_rootPath, "file1.S01E02.mkv")
}
}
};
Subject.Definition = new NotificationDefinition
{
Settings = new SynologyIndexerSettings
{
UpdateLibrary = true
}
};
}
[Test]
public void should_not_update_library_if_disabled()
{
(Subject.Definition.Settings as SynologyIndexerSettings).UpdateLibrary = false;
Subject.OnRename(_artist, new List<RenamedTrackFile>());
Mocker.GetMock<ISynologyIndexerProxy>()
.Verify(v => v.UpdateFolder(_artist.Path), Times.Never());
}
[Test]
public void should_remove_old_episodes_on_upgrade()
{
Subject.OnReleaseImport(_upgrade);
Mocker.GetMock<ISynologyIndexerProxy>()
.Verify(v => v.DeleteFile(@"C:\Test\file1.S01E01.mkv".AsOsAgnostic()), Times.Once());
Mocker.GetMock<ISynologyIndexerProxy>()
.Verify(v => v.DeleteFile(@"C:\Test\file1.S01E02.mkv".AsOsAgnostic()), Times.Once());
}
[Test]
public void should_add_new_episode_on_upgrade()
{
Subject.OnReleaseImport(_upgrade);
Mocker.GetMock<ISynologyIndexerProxy>()
.Verify(v => v.AddFile(@"C:\Test\file1.S01E01E02.mkv".AsOsAgnostic()), Times.Once());
}
[Test]
public void should_update_entire_series_folder_on_rename()
{
Subject.OnRename(_artist, new List<RenamedTrackFile>());
Mocker.GetMock<ISynologyIndexerProxy>()
.Verify(v => v.UpdateFolder(@"C:\Test\".AsOsAgnostic()), Times.Once());
}
}
}