Added some tests for PagingSpecExtensions

Allow specials in missing
Dropped ListSortDirection
This commit is contained in:
Mark McDowall
2013-05-07 00:22:19 -07:00
parent d37c8c26c2
commit f4dd6adc6a
12 changed files with 131 additions and 92 deletions
@@ -1,25 +0,0 @@
using System.ComponentModel;
using FluentAssertions;
using NUnit.Framework;
using NzbDrone.Core.Datastore;
using NzbDrone.Core.Tv;
namespace NzbDrone.Core.Test.Datastore.PagingSpecExtenstionsTests
{
public class OrderByClauseFixture
{
[Test]
public void Test()
{
var pagingSpec = new PagingSpec<Episode>
{
Page = 1,
PageSize = 10,
SortDirection = ListSortDirection.Ascending,
SortKey = "AirDate"
};
pagingSpec.OrderByClause().Should().NotBeNullOrEmpty();
}
}
}
@@ -0,0 +1,31 @@
using System;
using System.ComponentModel;
using System.Linq.Expressions;
using FluentAssertions;
using NUnit.Framework;
using NzbDrone.Core.Datastore;
using NzbDrone.Core.Tv;
namespace NzbDrone.Core.Test.Datastore.PagingSpecExtenstionsTests
{
public class PagingOffsetFixture
{
[TestCase(1, 10, 0)]
[TestCase(2, 10, 10)]
[TestCase(3, 20, 40)]
[TestCase(1, 100, 0)]
public void should_calcuate_expected_offset(int page, int pageSize, int expected)
{
var pagingSpec = new PagingSpec<Episode>
{
Page = page,
PageSize = pageSize,
SortDirection = SortDirection.Ascending,
SortKey = "AirDate"
};
pagingSpec.PagingOffset().Should().Be(expected);
}
}
}
@@ -0,0 +1,41 @@
using System;
using System.ComponentModel;
using System.Linq.Expressions;
using FluentAssertions;
using NUnit.Framework;
using NzbDrone.Core.Datastore;
using NzbDrone.Core.Tv;
namespace NzbDrone.Core.Test.Datastore.PagingSpecExtenstionsTests
{
public class ToSortDirectionFixture
{
[Test]
public void should_convert_ascending_to_asc()
{
var pagingSpec = new PagingSpec<Episode>
{
Page = 1,
PageSize = 10,
SortDirection = SortDirection.Ascending,
SortKey = "AirDate"
};
pagingSpec.ToSortDirection().Should().Be(Marr.Data.QGen.SortDirection.Asc);
}
[Test]
public void should_convert_descending_to_desc()
{
var pagingSpec = new PagingSpec<Episode>
{
Page = 1,
PageSize = 10,
SortDirection = SortDirection.Descending,
SortKey = "AirDate"
};
pagingSpec.ToSortDirection().Should().Be(Marr.Data.QGen.SortDirection.Desc);
}
}
}