/// <summary> /// Test that GetQueryResultsAsync throw NotSupportedException with a unsuortable repository and a valid orderBy /// </summary> public async void GetQueryResultsAsyncThrowNotSupportedExceptionOnUnsortableRepository() { HRCoreRepositoryStub repo = new HRCoreRepositoryStub(); repo._isSortable = false; HRServiceWorkflowPaginationOnly <int> classic = new HRServiceWorkflowPaginationOnly <int>(repo, new HRPaginer <int>()); await Assert.ThrowsAsync <NotSupportedException>(async() => await classic.GetQueryResultsAsync(new PagingParameterInModel(), new HRSortingParamModel() { SortingParamsQuery = "name;asc" }));; }
/// <summary> /// Test that GetQueryResultsAsync with invalid PageModel throw InvalidProgramException /// </summary> public async void GetQueryResultsAsyncWithInvalidPageModelThrowInvalidProgramException() { HRCoreRepositoryStub repo = new HRCoreRepositoryStub(); repo._isSortable = true; repo._isPaginable = false; HRServiceWorkflowPaginationOnly <int> classic = new HRServiceWorkflowPaginationOnly <int>(repo, new HRPaginer <int>()); await Assert.ThrowsAsync <InvalidProgramException>(async() => await classic.GetQueryResultsAsync( new PagingParameterInModel() { PageNumber = 500, PageSize = 10 }, new HRSortingParamModel() { SortingParamsQuery = "name;asc" })); }
/// <summary> /// Test that GetQueryResultsAsync Retrun SortableAndPAginable from repo with a valid orderBy /// </summary> public async void GetQueryResultsAsyncRetrunRepositoryGetOrderedAndPaginatedsAsync() { HRCoreRepositoryStub repo = new HRCoreRepositoryStub(); repo._isSortable = true; HRServiceWorkflowPaginationOnly <int> classic = new HRServiceWorkflowPaginationOnly <int>(repo, new HRPaginer <int>()); Task <PagingParameterOutModel <int> > task = classic.GetQueryResultsAsync( new PagingParameterInModel(), new HRSortingParamModel() { SortingParamsQuery = "name;asc" }); await task; Assert.NotNull(task); Assert.NotNull(task.Result); Assert.Equal(42, task.Result.CurrentPage); }
/// <summary> /// Test that GetQueryResultsAsync Retrun GetFullsAsync from unpaginable repo without ordering. /// /// </summary> public async void GetQueryResultsAsyncRetrunRepositoryGetFullsAsync() { HRCoreRepositoryStub repo = new HRCoreRepositoryStub(); repo._isSortable = true; repo._isPaginable = false; HRServiceWorkflowPaginationOnly <int> classic = new HRServiceWorkflowPaginationOnly <int>(repo, new HRPaginer <int>()); Task <PagingParameterOutModel <int> > task = classic.GetQueryResultsAsync( new PagingParameterInModel() { PageNumber = 0, PageSize = 10 }, null); await task; Assert.NotNull(task); Assert.NotNull(task.Result); Assert.NotNull(task.Result.PageItems); Assert.True(task.Result.PageItems.ToList()[0] == 45); }
public HRServiceWorkflowPaginationOnlyTest() { _repo = new HRCoreRepositoryStub(); _stubbedPagination = new HRServiceWorkflowPaginationOnly <int>(_repo, new HRPaginer <int>()); }