CreateLinkValueCollection_Returns_LinkValueCollection_Without_Next_LinkValue() { _pagedCollection.HasNext = false; var result = LinkValueHelpers.CreateLinkValueCollection( _linkTargetUri, _pagedCollection); var linkValues = result as LinkValue[] ?? result.ToArray(); Assert.Equal( 2, linkValues.Length); Assert.Contains( _start, linkValues, new LinkValueComparer()); Assert.Contains( _previous, linkValues, new LinkValueComparer()); Assert.DoesNotContain( _next, linkValues, new LinkValueComparer()); }
CreateLinkValueCollection_Throws_When_PagedCollection_Is_Null() { Assert.Throws <ArgumentNullException>( "pagedCollection", () => LinkValueHelpers.CreateLinkValueCollection( new Uri("http://localhost/"), (IPagedCollection <object>)null)); }
CreateLinkValueCollection_Throws_When_LinkTargetUri_Is_Null() { Assert.Throws <ArgumentNullException>( "linkTargetUri", () => LinkValueHelpers.CreateLinkValueCollection( null, new ObjectPagedCollection())); }
public static IEnumerable <LinkValue> GetLinkValues <TItem>( this ActionContext context, IPagedCollection <TItem> pagedCollection) { if (context == null) { throw new ArgumentNullException(nameof(context)); } if (pagedCollection == null) { return(Enumerable.Empty <LinkValue>()); } return(LinkValueHelpers.CreateLinkValueCollection( new Uri(context.HttpContext.Request.GetDisplayUrl()), pagedCollection)); }
public void CreateLinkValueCollection_Returns_LinkValueCollection() { var result = LinkValueHelpers.CreateLinkValueCollection( _linkTargetUri, _pagedCollection); var linkValues = result as LinkValue[] ?? result.ToArray(); Assert.Contains( _start, linkValues, _comparer); Assert.Contains( _previous, linkValues, _comparer); Assert.Contains( _next, linkValues, _comparer); }
CreateLinkValueCollection_Returns_LinkValueCollection_Without_Previous_LinkValue() { _pagedCollection.HasPrevious = false; var result = LinkValueHelpers.CreateLinkValueCollection( _linkTargetUri, _pagedCollection); var linkValues = result as LinkValue[] ?? result.ToArray(); Assert.Contains( _start, linkValues, _comparer); Assert.Contains( _next, linkValues, _comparer); Assert.DoesNotContain( _previous, linkValues, _comparer); }