2011-09-14 02:25:33 +00:00
|
|
|
// ReSharper disable RedundantUsingDirective
|
2011-10-20 23:42:17 +00:00
|
|
|
|
2011-09-14 02:25:33 +00:00
|
|
|
using System.Collections.Generic;
|
2011-11-14 00:22:18 +00:00
|
|
|
|
2011-09-14 02:25:33 +00:00
|
|
|
using FizzWare.NBuilder;
|
|
|
|
using FluentAssertions;
|
|
|
|
using NUnit.Framework;
|
|
|
|
using NzbDrone.Core.Providers;
|
|
|
|
using NzbDrone.Core.Repository.Quality;
|
|
|
|
using NzbDrone.Core.Test.Framework;
|
2011-11-14 00:22:18 +00:00
|
|
|
using NzbDrone.Test.Common.AutoMoq;
|
2011-09-14 02:25:33 +00:00
|
|
|
|
2011-10-20 23:42:17 +00:00
|
|
|
namespace NzbDrone.Core.Test.ProviderTests
|
2011-09-14 02:25:33 +00:00
|
|
|
{
|
|
|
|
[TestFixture]
|
|
|
|
// ReSharper disable InconsistentNaming
|
2013-02-02 20:54:03 +00:00
|
|
|
public class QualityTypeProviderTest : SqlCeTest
|
2011-09-14 02:25:33 +00:00
|
|
|
{
|
2013-01-19 23:55:58 +00:00
|
|
|
[SetUp]
|
|
|
|
public void SetuUp()
|
|
|
|
{
|
|
|
|
WithRealDb();
|
|
|
|
}
|
|
|
|
|
2011-09-14 02:25:33 +00:00
|
|
|
[Test]
|
2012-11-13 16:37:08 +00:00
|
|
|
public void SetupDefault_should_add_all_profiles()
|
2011-09-14 02:25:33 +00:00
|
|
|
{
|
2013-01-19 05:14:12 +00:00
|
|
|
Mocker.Resolve<QualityTypeProvider>();
|
2011-09-14 02:25:33 +00:00
|
|
|
|
2013-01-19 18:19:29 +00:00
|
|
|
|
2011-12-15 04:15:53 +00:00
|
|
|
var types = Mocker.Resolve<QualityTypeProvider>().All();
|
2011-09-14 02:25:33 +00:00
|
|
|
|
2013-01-09 08:20:35 +00:00
|
|
|
types.Should().HaveCount(10);
|
2011-09-14 02:25:33 +00:00
|
|
|
types.Should().Contain(e => e.Name == "SDTV" && e.QualityTypeId == 1);
|
|
|
|
types.Should().Contain(e => e.Name == "DVD" && e.QualityTypeId == 2);
|
2012-12-16 09:08:02 +00:00
|
|
|
types.Should().Contain(e => e.Name == "WEBDL-480p" && e.QualityTypeId == 8);
|
2013-01-01 03:45:57 +00:00
|
|
|
types.Should().Contain(e => e.Name == "HDTV-720p" && e.QualityTypeId == 4);
|
|
|
|
types.Should().Contain(e => e.Name == "HDTV-1080p" && e.QualityTypeId == 9);
|
2013-01-09 08:20:35 +00:00
|
|
|
types.Should().Contain(e => e.Name == "Raw-HD" && e.QualityTypeId == 10);
|
2012-11-13 16:37:08 +00:00
|
|
|
types.Should().Contain(e => e.Name == "WEBDL-720p" && e.QualityTypeId == 5);
|
|
|
|
types.Should().Contain(e => e.Name == "WEBDL-1080p" && e.QualityTypeId == 3);
|
2011-09-14 02:25:33 +00:00
|
|
|
types.Should().Contain(e => e.Name == "Bluray720p" && e.QualityTypeId == 6);
|
|
|
|
types.Should().Contain(e => e.Name == "Bluray1080p" && e.QualityTypeId == 7);
|
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
2012-10-15 04:30:07 +00:00
|
|
|
public void SetupDefault_already_exists_should_insert_missing()
|
2011-09-14 02:25:33 +00:00
|
|
|
{
|
|
|
|
|
2013-01-19 23:55:58 +00:00
|
|
|
Db.Insert(new QualityType { QualityTypeId = 1, Name = "SDTV", MinSize = 0, MaxSize = 100 });
|
2011-09-14 02:25:33 +00:00
|
|
|
|
2013-01-19 18:19:29 +00:00
|
|
|
|
2013-01-19 05:14:12 +00:00
|
|
|
Mocker.Resolve<QualityTypeProvider>();
|
2011-09-14 02:25:33 +00:00
|
|
|
|
2013-01-19 18:19:29 +00:00
|
|
|
|
2011-12-15 04:15:53 +00:00
|
|
|
var types = Mocker.Resolve<QualityTypeProvider>().All();
|
2011-09-14 02:25:33 +00:00
|
|
|
|
2013-01-01 03:45:57 +00:00
|
|
|
types.Should().HaveCount(QualityTypes.All().Count - 1);
|
2011-09-14 02:25:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void GetList_single_quality_type()
|
|
|
|
{
|
|
|
|
var fakeQualityTypes = Builder<QualityType>.CreateListOfSize(6)
|
|
|
|
.Build();
|
|
|
|
|
|
|
|
var ids = new List<int> { 1 };
|
|
|
|
|
2013-01-19 23:55:58 +00:00
|
|
|
Db.InsertMany(fakeQualityTypes);
|
2011-09-14 02:25:33 +00:00
|
|
|
|
2013-01-19 18:19:29 +00:00
|
|
|
|
2011-12-15 04:15:53 +00:00
|
|
|
var result = Mocker.Resolve<QualityTypeProvider>().GetList(ids);
|
2011-09-14 02:25:33 +00:00
|
|
|
|
2013-01-19 18:19:29 +00:00
|
|
|
|
2011-09-14 02:25:33 +00:00
|
|
|
result.Should().HaveCount(ids.Count);
|
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void GetList_multiple_quality_type()
|
|
|
|
{
|
|
|
|
var fakeQualityTypes = Builder<QualityType>.CreateListOfSize(6)
|
|
|
|
.Build();
|
|
|
|
|
|
|
|
var ids = new List<int> { 1, 2 };
|
|
|
|
|
2013-01-19 23:55:58 +00:00
|
|
|
Db.InsertMany(fakeQualityTypes);
|
2011-09-14 02:25:33 +00:00
|
|
|
|
2013-01-19 18:19:29 +00:00
|
|
|
|
2011-12-15 04:15:53 +00:00
|
|
|
var result = Mocker.Resolve<QualityTypeProvider>().GetList(ids);
|
2011-09-14 02:25:33 +00:00
|
|
|
|
2013-01-19 18:19:29 +00:00
|
|
|
|
2011-09-14 02:25:33 +00:00
|
|
|
result.Should().HaveCount(ids.Count);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|