mirror of
https://github.com/Radarr/Radarr.git
synced 2026-04-20 21:55:03 -04:00
7cfa0531dc
* First fixing of tests. * Updated more tests. * Fix some tests * Fix all prioritization tests. And add new for preferred words. * Updated CompletedDownloadservice tests * Fixed a lot of tests * Fixed all indexer requests. We should add more for the indexers we added. To lazy for that though ¯\_(ツ)_/¯ * Fixed organizer tests. Should probably be also updated to incorporate our newly added tags. * Fix notification tests. * Fixed update test for osx * Fixed a few more tests. * Fixed some more tests. * Update appveyor.yml * Update appveyor.yml * Update appveyor.yml * Update appveyor.yml * Update appveyor.yml * Update appveyor.yml * Update appveyor.yml * Update appveyor.yml * Update appveyor.yml * Update appveyor.yml * Update appveyor.yml * Update appveyor.yml * Update appveyor.yml * Update appveyor.yml * Update activity.less * Update appveyor.yml * Update appveyor.yml * Update CommonVersionInfo.cs * Update build-appveyor.cake Let's hope this works. * Update CommonVersionInfo.cs Just to kickstart appveyor * Fixed a few tests * Just ignore those tests. * Fixed more tests. * First steps in fixing Core.Test.Download.DownloadApprovedFixture * Fix most DownloadApprovedFixture tests * Fixed something. * Fixed a few more tests. * Fixed pending release tests. * All Core tests are now fixed. * Fixed the last tests :) * Fixed Download Station Tests. * Fixed Vuze and Transmission default settings which caused the tests to fail. * Fix most tests. * Fix RootFolder tests. * Fixed last tests
146 lines
4.7 KiB
C#
146 lines
4.7 KiB
C#
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using FizzWare.NBuilder;
|
|
using Moq;
|
|
using NUnit.Framework;
|
|
using NzbDrone.Common.Crypto;
|
|
using NzbDrone.Core.Download.Pending;
|
|
using NzbDrone.Core.Parser;
|
|
using NzbDrone.Core.Parser.Model;
|
|
using NzbDrone.Core.Test.Framework;
|
|
using NzbDrone.Core.Tv;
|
|
|
|
namespace NzbDrone.Core.Test.Download.Pending.PendingReleaseServiceTests
|
|
{
|
|
[TestFixture]
|
|
[Ignore("Series")]
|
|
public class RemovePendingFixture : CoreTest<PendingReleaseService>
|
|
{
|
|
private List<PendingRelease> _pending;
|
|
private Episode _episode;
|
|
|
|
[SetUp]
|
|
public void Setup()
|
|
{
|
|
_pending = new List<PendingRelease>();
|
|
|
|
_episode = Builder<Episode>.CreateNew()
|
|
.Build();
|
|
|
|
Mocker.GetMock<IPendingReleaseRepository>()
|
|
.Setup(s => s.AllBySeriesId(It.IsAny<int>()))
|
|
.Returns(_pending);
|
|
|
|
Mocker.GetMock<IPendingReleaseRepository>()
|
|
.Setup(s => s.All())
|
|
.Returns( _pending);
|
|
|
|
/*Mocker.GetMock<IMovieService>()
|
|
.Setup(s => s.GetMovie(It.IsAny<int>()))
|
|
.Returns(_movie);
|
|
|
|
Mocker.GetMock<IParsingService>()
|
|
.Setup(s => s.GetMovie(It.IsAny<string>()))
|
|
.Returns(_movie);*/
|
|
}
|
|
|
|
private void AddPending(int id, int seasonNumber, int[] episodes)
|
|
{
|
|
_pending.Add(new PendingRelease
|
|
{
|
|
Id = id,
|
|
ParsedEpisodeInfo = new ParsedEpisodeInfo { SeasonNumber = seasonNumber, EpisodeNumbers = episodes }
|
|
});
|
|
}
|
|
|
|
[Test]
|
|
public void should_remove_same_release()
|
|
{
|
|
AddPending(id: 1, seasonNumber: 2, episodes: new[] { 3 });
|
|
|
|
var queueId = HashConverter.GetHashInt31(string.Format("pending-{0}-ep{1}", 1, _episode.Id));
|
|
|
|
Subject.RemovePendingQueueItems(queueId);
|
|
|
|
AssertRemoved(1);
|
|
}
|
|
|
|
[Test]
|
|
public void should_remove_multiple_releases_release()
|
|
{
|
|
AddPending(id: 1, seasonNumber: 2, episodes: new[] { 1 });
|
|
AddPending(id: 2, seasonNumber: 2, episodes: new[] { 2 });
|
|
AddPending(id: 3, seasonNumber: 2, episodes: new[] { 3 });
|
|
AddPending(id: 4, seasonNumber: 2, episodes: new[] { 3 });
|
|
|
|
var queueId = HashConverter.GetHashInt31(string.Format("pending-{0}-ep{1}", 3, _episode.Id));
|
|
|
|
Subject.RemovePendingQueueItems(queueId);
|
|
|
|
AssertRemoved(3, 4);
|
|
}
|
|
|
|
[Test]
|
|
public void should_not_remove_diffrent_season()
|
|
{
|
|
AddPending(id: 1, seasonNumber: 2, episodes: new[] { 1 });
|
|
AddPending(id: 2, seasonNumber: 2, episodes: new[] { 1 });
|
|
AddPending(id: 3, seasonNumber: 3, episodes: new[] { 1 });
|
|
AddPending(id: 4, seasonNumber: 3, episodes: new[] { 1 });
|
|
|
|
var queueId = HashConverter.GetHashInt31(string.Format("pending-{0}-ep{1}", 1, _episode.Id));
|
|
|
|
Subject.RemovePendingQueueItems(queueId);
|
|
|
|
AssertRemoved(1, 2);
|
|
}
|
|
|
|
[Test]
|
|
public void should_not_remove_diffrent_episodes()
|
|
{
|
|
AddPending(id: 1, seasonNumber: 2, episodes: new[] { 1 });
|
|
AddPending(id: 2, seasonNumber: 2, episodes: new[] { 1 });
|
|
AddPending(id: 3, seasonNumber: 2, episodes: new[] { 2 });
|
|
AddPending(id: 4, seasonNumber: 2, episodes: new[] { 3 });
|
|
|
|
var queueId = HashConverter.GetHashInt31(string.Format("pending-{0}-ep{1}", 1, _episode.Id));
|
|
|
|
Subject.RemovePendingQueueItems(queueId);
|
|
|
|
AssertRemoved(1, 2);
|
|
}
|
|
|
|
[Test]
|
|
public void should_not_remove_multiepisodes()
|
|
{
|
|
AddPending(id: 1, seasonNumber: 2, episodes: new[] { 1 });
|
|
AddPending(id: 2, seasonNumber: 2, episodes: new[] { 1, 2 });
|
|
|
|
var queueId = HashConverter.GetHashInt31(string.Format("pending-{0}-ep{1}", 1, _episode.Id));
|
|
|
|
Subject.RemovePendingQueueItems(queueId);
|
|
|
|
AssertRemoved(1);
|
|
}
|
|
|
|
[Test]
|
|
public void should_not_remove_singleepisodes()
|
|
{
|
|
AddPending(id: 1, seasonNumber: 2, episodes: new[] { 1 });
|
|
AddPending(id: 2, seasonNumber: 2, episodes: new[] { 1, 2 });
|
|
|
|
var queueId = HashConverter.GetHashInt31(string.Format("pending-{0}-ep{1}", 2, _episode.Id));
|
|
|
|
Subject.RemovePendingQueueItems(queueId);
|
|
|
|
AssertRemoved(2);
|
|
}
|
|
|
|
private void AssertRemoved(params int[] ids)
|
|
{
|
|
Mocker.GetMock<IPendingReleaseRepository>().Verify(c => c.DeleteMany(It.Is<IEnumerable<int>>(s => s.SequenceEqual(ids))));
|
|
}
|
|
}
|
|
|
|
}
|