71 lines
2.5 KiB
C#
71 lines
2.5 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using Xunit;
|
|
using Aurora;
|
|
using Aurora.Services.Signal;
|
|
|
|
|
|
namespace AuroraSignal.test
|
|
{
|
|
public class CursorListTest
|
|
{
|
|
[Theory()]
|
|
[InlineData(SortDirection.Asc)]
|
|
[InlineData(SortDirection.Desc)]
|
|
public void CursorListSortOnStringValue(SortDirection direction)
|
|
{
|
|
CursorList<Party> cursor = new CursorList<Party>();
|
|
cursor.Add(new Party(){Name = "asdf", PartyId = "1111"});
|
|
cursor.Add(new Party(){Name = "bsdf", PartyId = "2222"});
|
|
cursor.Add(new Party(){Name = "csdf", PartyId = "3333"});
|
|
|
|
List<Party> result = cursor.WithSort("Name", direction).Get();
|
|
|
|
if(direction == SortDirection.Desc)
|
|
{
|
|
Assert.Collection<Party>(cursor,
|
|
item => item.Name.Equals("asdf"),
|
|
item => item.Name.Equals("bsdf"),
|
|
item => item.Name.Equals("csdf"));
|
|
}
|
|
else
|
|
{
|
|
Assert.Collection<Party>(cursor,
|
|
item => item.Name.Equals("csdf"),
|
|
item => item.Name.Equals("bsdf"),
|
|
item => item.Name.Equals("asdf"));
|
|
|
|
}
|
|
}
|
|
|
|
[Theory()]
|
|
[InlineData(SortDirection.Asc)]
|
|
[InlineData(SortDirection.Desc)]
|
|
public void CursorListSortOnIntValue(SortDirection direction)
|
|
{
|
|
CursorList<object> cursor = new CursorList<object>();
|
|
cursor.Add(new {Name = "asdf", PartyId = 1111});
|
|
cursor.Add(new {Name = "bsdf", PartyId = 2222});
|
|
cursor.Add(new {Name = "csdf", PartyId = 3333});
|
|
|
|
List<object> result = cursor.WithSort("PartyId", direction).Get();
|
|
|
|
if(direction == SortDirection.Desc)
|
|
{
|
|
Assert.Collection<object>(cursor,
|
|
item => item.Equals(new {Name = "asdf", PartyId = 1111}),
|
|
item => item.Equals(new {Name = "bsdf", PartyId = 2222}),
|
|
item => item.Equals(new {Name = "csdf", PartyId = 3333}));
|
|
}
|
|
else
|
|
{
|
|
Assert.Collection<object>(cursor,
|
|
item => item.Equals(new {Name = "csdf", PartyId = 3333}),
|
|
item => item.Equals(new {Name = "bsdf", PartyId = 2222}),
|
|
item => item.Equals(new {Name = "asdf", PartyId = 1111}));
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|