ExecuteResultAsync_Adds_WebLinks_Only_If_Response_Has_Not_Started( bool responseHasStarted, int numLinkAddedToHeaders) { _httpResponseFeature .SetupGet(x => x.HasStarted) .Returns(responseHasStarted); var pagedCollectionResult = new PagedCollectionResult <object>(_pagedCollectionMock.Object); var actionContext = new ActionContext( CreateDefaultHttpContext(), new RouteData(), new ActionDescriptor()); await pagedCollectionResult.ExecuteResultAsync(actionContext) .ConfigureAwait(false); _headerDictionaryMock.Verify( x => x.Add( It.Is <string>(y => y == "Link"), It.IsAny <StringValues>()), Times.Exactly(numLinkAddedToHeaders)); _actionResultExecutorMock.Verify( x => x.ExecuteAsync( It.Is <ActionContext>(y => y == actionContext), It.Is <ObjectResult>(z => z == pagedCollectionResult))); }
public void ExecuteResultAsync_Throws_When_Context_Is_Null() { var pagedCollectionResult = new PagedCollectionResult <object>(_pagedCollectionMock.Object); Assert.ThrowsAsync <ArgumentNullException>( () => pagedCollectionResult.ExecuteResultAsync(null)); }
public PagedCollectionResult <T> Adapt <S, T>(PagedCollectionResultDTO <S> source) where T : IExampleModel <S>, new() { var target = new PagedCollectionResult <T>(); target.Page = source.Page; target.Page = source.PageSize; target.Total = source.Total; target.Data = AdaptList <S, T>(source.Data).ToList(); return(target); }