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.
Radarr/src/NzbDrone.Core.Test/Download/Pending/PendingReleaseServiceTests/RemovePendingFixture.cs

78 lines
2.3 KiB

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.Movies;
using NzbDrone.Core.Parser;
using NzbDrone.Core.Parser.Model;
using NzbDrone.Core.Test.Framework;
namespace NzbDrone.Core.Test.Download.Pending.PendingReleaseServiceTests
{
[TestFixture]
public class RemovePendingFixture : CoreTest<PendingReleaseService>
{
private List<PendingRelease> _pending;
private Movie _movie;
[SetUp]
public void Setup()
{
_pending = new List<PendingRelease>();
_movie = Builder<Movie>.CreateNew()
.Build();
Mocker.GetMock<IPendingReleaseRepository>()
.Setup(s => s.AllByMovieId(It.IsAny<int>()))
.Returns(_pending);
Mocker.GetMock<IPendingReleaseRepository>()
.Setup(s => s.All())
.Returns(_pending);
Mocker.GetMock<IMovieService>()
Fixed all tests and even added some new ones :) (#835) * 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
8 years ago
.Setup(s => s.GetMovie(It.IsAny<int>()))
.Returns(_movie);
Mocker.GetMock<IMovieService>()
.Setup(s => s.GetMovies(It.IsAny<IEnumerable<int>>()))
.Returns(new List<Movie> { _movie });
Mocker.GetMock<IParsingService>()
Fixed all tests and even added some new ones :) (#835) * 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
8 years ago
.Setup(s => s.GetMovie(It.IsAny<string>()))
.Returns(_movie);
}
private void AddPending(int id, string title, int year)
{
_pending.Add(new PendingRelease
{
Id = id,
ParsedMovieInfo = new ParsedMovieInfo { MovieTitles = new List<string> { title }, Year = year },
MovieId = _movie.Id
});
}
[Test]
public void should_remove_same_release()
{
AddPending(id: 1, title: "Movie", year: 2001);
var queueId = HashConverter.GetHashInt31(string.Format("pending-{0}-movie{1}", 1, _movie.Id));
Subject.RemovePendingQueueItems(queueId);
AssertRemoved(1);
}
private void AssertRemoved(params int[] ids)
{
Mocker.GetMock<IPendingReleaseRepository>().Verify(c => c.DeleteMany(It.Is<IEnumerable<int>>(s => s.SequenceEqual(ids))));
}
}
}