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 cursor = new CursorList(); 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 result = cursor.WithSort("Name", direction).Get(); if(direction == SortDirection.Desc) { Assert.Collection(cursor, item => item.Name.Equals("asdf"), item => item.Name.Equals("bsdf"), item => item.Name.Equals("csdf")); } else { Assert.Collection(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 cursor = new CursorList(); cursor.Add(new {Name = "asdf", PartyId = 1111}); cursor.Add(new {Name = "bsdf", PartyId = 2222}); cursor.Add(new {Name = "csdf", PartyId = 3333}); List result = cursor.WithSort("PartyId", direction).Get(); if(direction == SortDirection.Desc) { Assert.Collection(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(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})); } } } }