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 void CreateLinkValue_Throws_When_Uri_Is_Null() { Assert.Throws <ArgumentNullException>( "linkTargetUri", () => LinkValueHelpers.CreateLinkValue( null, "relationType", int.MaxValue, int.MaxValue)); }
CreateLinkValue_Throws_When_RelationType_Is_NullEmptyOrWhitespace( string value) { Assert.Throws <ArgumentException>( "relationType", () => LinkValueHelpers.CreateLinkValue( new Uri("http://localhost/"), value, int.MaxValue, int.MaxValue)); }
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 CreateLinkValue_Returns_LinkValue( string expected, string value, int offset, int limit) { var relationType = "relationType"; var result = LinkValueHelpers.CreateLinkValue( new Uri(value), relationType, offset, limit); Assert.NotNull(result); Assert.Contains( relationType, result.RelationType.Relations); Assert.Equal( expected, result.TargetUri.ToString()); }
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); }