Skip to content

Commit

Permalink
Merge pull request #70 from tpeplow/master
Browse files Browse the repository at this point in the history
maintain title of templated link when creating a non-templated version
  • Loading branch information
JakeGinnivan committed Sep 12, 2014
2 parents b5bdc45 + a6ea81d commit 2ad999c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
13 changes: 13 additions & 0 deletions WebApi.Hal.Tests/UriBuilderTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -111,5 +111,18 @@ public void create_uri_absolute()
// assert
Assert.Equal("http://myserver.com/api/beers/BeerName", link.ToString());
}

[Fact]
public void create_link_uses_templates_title()
{
// arrange
var templateLink = new Link("beerbyname", "http://myserver.com/api/beers{name}", "Beer");

// act
var link = templateLink.CreateLink(new {name = "BeerName"});

// assert
Assert.Equal(link.Title, "Beer");
}
}
}
2 changes: 1 addition & 1 deletion WebApi.Hal/Link.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public bool IsTemplated
/// <returns>A non templated link</returns>
public Link CreateLink(string newRel, params object[] parameters)
{
return new Link(newRel, CreateUri(parameters).ToString());
return new Link(newRel, CreateUri(parameters).ToString(), Title);
}

/// <summary>
Expand Down

0 comments on commit 2ad999c

Please sign in to comment.