aurora/AuroraSignal.test/CursorList.test.cs

43 lines
1.3 KiB
C#
Raw Normal View History

using Xunit;
using Aurora;
using Aurora.Services.Signal;
2021-03-05 16:56:51 +00:00
using Aurora.Cursor;
namespace AuroraSignal.test
{
public class CursorListTest
{
[Theory()]
[InlineData(SortDirection.Asc)]
[InlineData(SortDirection.Desc)]
public void CursorListSortOnStringValue(SortDirection direction)
{
2021-03-05 16:56:51 +00:00
CursorList<Party> list = new CursorList<Party>();
list.Add(new Party() { Name = "asdf", Id = "1111" });
list.Add(new Party() { Name = "bsdf", Id = "2222" });
list.Add(new Party() { Name = "csdf", Id = "3333" });
2021-03-05 16:56:51 +00:00
CursorResult<Party> result = new Cursor<Party>(ref list)
.WithSort(item => item.Value.Name, direction)
.GetNextPage();
2021-03-05 16:56:51 +00:00
if (direction == SortDirection.Desc)
{
2021-03-05 16:56:51 +00:00
Assert.Collection<Party>(result.Result,
item => item.Name.Equals("asdf"),
item => item.Name.Equals("bsdf"),
item => item.Name.Equals("csdf"));
}
else
{
2021-03-05 16:56:51 +00:00
Assert.Collection<Party>(result.Result,
item => item.Name.Equals("csdf"),
item => item.Name.Equals("bsdf"),
item => item.Name.Equals("asdf"));
}
}
}
}