using System; using System.Linq; using Centron.BusinessLogic; using Centron.BusinessLogic.Sales.Support; using Centron.Data.Entities.Sales.Support; using Centron.Tests.EndToEnd.Infrastructure; using Xunit; using Xunit.Abstractions; namespace Centron.Tests.EndToEnd.Tests.Helpdesk { public class HelpdeskSearchPagingTests : EndToEndTest { public HelpdeskSearchPagingTests(ITestOutputHelper testOutputHelper) : base(testOutputHelper) { } public override void Execute() { using (var session = new BLSession()) { var resultPage1 = session.GetBL().GetHelpdesksThroughPaging(new HelpdeskFilter() { OnlyActive = true }, HelpdeskSort.CreateDate, true, 1, 10, GetLoggedInUser()); Verifier.Verify("HelpdeskSearchPagingTests_Page1", resultPage1.Data); var resultPage2 = session.GetBL().GetHelpdesksThroughPaging(new HelpdeskFilter() { OnlyActive = true }, HelpdeskSort.CreateDate, true, 2, 10, GetLoggedInUser()); Verifier.Verify("HelpdeskSearchPagingTests_Page2", resultPage2.Data); var searchWithoutPagingResult = session.GetBL().GetHelpdesksThroughPaging(new HelpdeskFilter() { OnlyActive = true }, HelpdeskSort.CreateDate, true, 0, 0, GetLoggedInUser()); // we truncate the result list to first 20 entries (should contain the entries from previews Page1 and Page2 test searchWithoutPagingResult.Data.Result = searchWithoutPagingResult.Data.Result.Take(20).ToList(); Verifier.Verify("HelpdeskSearchPagingTests_First20Entries", searchWithoutPagingResult.Data); // compare paging data with data without paging for (int i = 0; i < 10; i++) { Assert.True(resultPage1.Data.Result[i].I3D == searchWithoutPagingResult.Data.Result[i].I3D, $"resultPage1(idx:{i}) ticket I3D does not match with searchWithoutPaging list"); Assert.True(resultPage2.Data.Result[i].I3D == searchWithoutPagingResult.Data.Result[i+10].I3D, $"resultPage2(idx:{i}) ticket I3D does not match with searchWithoutPaging list"); } } } } }