1
0
Fork 0
mirror of https://github.com/Sonarr/Sonarr synced 2024-12-28 10:48:46 +00:00
Sonarr/NzbDrone.Core.Test/Qualities/QualityFixture.cs

123 lines
3.4 KiB
C#
Raw Normal View History

2013-07-19 03:47:55 +00:00
using FluentAssertions;
2012-10-14 00:36:16 +00:00
using NUnit.Framework;
2013-02-27 03:19:22 +00:00
using NzbDrone.Core.Qualities;
2012-10-14 00:36:16 +00:00
using NzbDrone.Core.Test.Framework;
2013-02-27 03:19:22 +00:00
namespace NzbDrone.Core.Test.Qualities
2012-10-14 00:36:16 +00:00
{
[TestFixture]
2013-02-27 03:19:22 +00:00
public class QualityFixture : CoreTest
2012-10-14 00:36:16 +00:00
{
public static object[] FromIntCases =
{
2013-02-27 03:19:22 +00:00
new object[] {1, Quality.SDTV},
new object[] {2, Quality.DVD},
new object[] {4, Quality.HDTV720p},
new object[] {5, Quality.WEBDL720p},
new object[] {6, Quality.Bluray720p},
new object[] {7, Quality.Bluray1080p}
2012-10-14 00:36:16 +00:00
};
public static object[] ToIntCases =
{
2013-02-27 03:19:22 +00:00
new object[] {Quality.SDTV, 1},
new object[] {Quality.DVD, 2},
new object[] {Quality.HDTV720p, 4},
new object[] {Quality.WEBDL720p, 5},
new object[] {Quality.Bluray720p, 6},
new object[] {Quality.Bluray1080p, 7}
2012-10-14 00:36:16 +00:00
};
[Test, TestCaseSource("FromIntCases")]
2013-02-27 03:19:22 +00:00
public void should_be_able_to_convert_int_to_qualityTypes(int source, Quality expected)
2012-10-14 00:36:16 +00:00
{
2013-02-27 03:19:22 +00:00
var quality = (Quality)source;
2012-10-14 00:36:16 +00:00
quality.Should().Be(expected);
}
[Test, TestCaseSource("ToIntCases")]
2013-02-27 03:19:22 +00:00
public void should_be_able_to_convert_qualityTypes_to_int(Quality source, int expected)
2012-10-14 00:36:16 +00:00
{
var i = (int)source;
i.Should().Be(expected);
}
[Test]
public void Icomparer_greater_test()
{
2013-02-27 03:19:22 +00:00
var first = Quality.DVD;
var second = Quality.Bluray1080p;
2012-10-14 00:36:16 +00:00
second.Should().BeGreaterThan(first);
}
[Test]
public void Icomparer_lesser()
{
2013-02-27 03:19:22 +00:00
var first = Quality.DVD;
var second = Quality.Bluray1080p;
2012-10-14 00:36:16 +00:00
first.Should().BeLessThan(second);
}
[Test]
public void equal_operand()
{
2013-02-27 03:19:22 +00:00
var first = Quality.Bluray1080p;
var second = Quality.Bluray1080p;
2012-10-14 00:36:16 +00:00
(first == second).Should().BeTrue();
(first >= second).Should().BeTrue();
(first <= second).Should().BeTrue();
}
[Test]
public void equal_operand_false()
{
2013-02-27 03:19:22 +00:00
var first = Quality.Bluray1080p;
var second = Quality.Unknown;
2012-10-14 00:36:16 +00:00
(first == second).Should().BeFalse();
}
[Test]
public void not_equal_operand()
{
2013-02-27 03:19:22 +00:00
var first = Quality.Bluray1080p;
var second = Quality.Bluray1080p;
2012-10-14 00:36:16 +00:00
(first != second).Should().BeFalse();
}
[Test]
public void not_equal_operand_false()
{
2013-02-27 03:19:22 +00:00
var first = Quality.Bluray1080p;
var second = Quality.Unknown;
2012-10-14 00:36:16 +00:00
(first != second).Should().BeTrue();
}
[Test]
public void greater_operand()
{
2013-02-27 03:19:22 +00:00
var first = Quality.DVD;
var second = Quality.Bluray1080p;
2012-10-14 00:36:16 +00:00
(first < second).Should().BeTrue();
(first <= second).Should().BeTrue();
}
[Test]
public void lesser_operand()
{
2013-02-27 03:19:22 +00:00
var first = Quality.DVD;
var second = Quality.Bluray1080p;
2012-10-14 00:36:16 +00:00
(second > first).Should().BeTrue();
(second >= first).Should().BeTrue();
}
}
}