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/QueueTests/QueueServiceFixture.cs

79 lines
2.4 KiB

using System;
using System.Collections.Generic;
using System.Linq;
using FizzWare.NBuilder;
using FluentAssertions;
using Moq;
using NUnit.Framework;
using NzbDrone.Core.Download;
using NzbDrone.Core.Download.TrackedDownloads;
using NzbDrone.Core.History;
using NzbDrone.Core.Music;
using NzbDrone.Core.Parser.Model;
using NzbDrone.Core.Queue;
using NzbDrone.Core.Test.Framework;
namespace NzbDrone.Core.Test.QueueTests
{
[TestFixture]
public class QueueServiceFixture : CoreTest<QueueService>
{
private List<TrackedDownload> _trackedDownloads;
[SetUp]
public void SetUp()
{
var downloadClientInfo = Builder<DownloadClientItemClientInfo>.CreateNew().Build();
var downloadItem = Builder<NzbDrone.Core.Download.DownloadClientItem>.CreateNew()
.With(v => v.RemainingTime = TimeSpan.FromSeconds(10))
.With(v => v.DownloadClientInfo = downloadClientInfo)
.Build();
var artist = Builder<Artist>.CreateNew()
.Build();
var albums = Builder<Album>.CreateListOfSize(3)
.All()
.With(e => e.ArtistId = artist.Id)
.Build();
var remoteAlbum = Builder<RemoteAlbum>.CreateNew()
.With(r => r.Artist = artist)
.With(r => r.Albums = new List<Album>(albums))
.With(r => r.ParsedAlbumInfo = new ParsedAlbumInfo())
.Build();
_trackedDownloads = Builder<TrackedDownload>.CreateListOfSize(1)
.All()
.With(v => v.DownloadItem = downloadItem)
.With(v => v.RemoteAlbum = remoteAlbum)
.Build()
.ToList();
var historyItem = Builder<EntityHistory>.CreateNew()
.Build();
Mocker.GetMock<IHistoryService>()
.Setup(c => c.Find(It.IsAny<string>(), EntityHistoryEventType.Grabbed)).Returns(
new List<EntityHistory> { historyItem });
}
[Test]
public void queue_items_should_have_id()
{
Subject.Handle(new TrackedDownloadRefreshedEvent(_trackedDownloads));
var queue = Subject.GetQueue();
queue.Should().HaveCount(3);
queue.All(v => v.Id > 0).Should().BeTrue();
var distinct = queue.Select(v => v.Id).Distinct().ToArray();
distinct.Should().HaveCount(3);
}
}
}