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/HistoryTests/HistoryServiceFixture.cs

60 lines
2.0 KiB

using NUnit.Framework;
using NzbDrone.Core.Profiles;
using NzbDrone.Core.Test.Framework;
using NzbDrone.Core.History;
using NzbDrone.Core.Qualities;
using System.Collections.Generic;
using NzbDrone.Core.Test.Qualities;
using FluentAssertions;
namespace NzbDrone.Core.Test.HistoryTests
{
public class HistoryServiceFixture : CoreTest<HistoryService>
{
private Profile _profile;
private Profile _profileCustom;
[SetUp]
public void Setup()
{
_profile = new Profile { Cutoff = Quality.WEBDL720p, Items = QualityFixture.GetDefaultQualities() };
_profileCustom = new Profile { Cutoff = Quality.WEBDL720p, Items = QualityFixture.GetDefaultQualities(Quality.DVD) };
}
[Test]
public void should_return_null_if_no_history()
{
Mocker.GetMock<IHistoryRepository>()
.Setup(v => v.GetBestQualityInHistory(2))
.Returns(new List<QualityModel>());
var quality = Subject.GetBestQualityInHistory(_profile, 2);
quality.Should().BeNull();
}
[Test]
public void should_return_best_quality()
{
Mocker.GetMock<IHistoryRepository>()
.Setup(v => v.GetBestQualityInHistory(2))
.Returns(new List<QualityModel> { new QualityModel(Quality.DVD), new QualityModel(Quality.Bluray1080p) });
var quality = Subject.GetBestQualityInHistory(_profile, 2);
quality.Should().Be(new QualityModel(Quality.Bluray1080p));
}
[Test]
public void should_return_best_quality_with_custom_order()
{
Mocker.GetMock<IHistoryRepository>()
.Setup(v => v.GetBestQualityInHistory(2))
.Returns(new List<QualityModel> { new QualityModel(Quality.DVD), new QualityModel(Quality.Bluray1080p) });
var quality = Subject.GetBestQualityInHistory(_profileCustom, 2);
quality.Should().Be(new QualityModel(Quality.DVD));
}
}
}