本文整理汇总了C#中Link.CreateLink方法的典型用法代码示例。如果您正苦于以下问题:C# Link.CreateLink方法的具体用法?C# Link.CreateLink怎么用?C# Link.CreateLink使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Link
的用法示例。
在下文中一共展示了Link.CreateLink方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: create_link_handles_spaces
public void create_link_handles_spaces()
{
// arrange
var templateLink = new Link("beerbyname", "/beers/{name}");
// act
var link = templateLink.CreateLink(new { name = "Tactical Nuclear Penguin" });
// assert
Assert.Equal("/beers/Tactical%20Nuclear%20Penguin", link.Href);
}
示例2: create_link_substitution_is_case_sensitive1
public void create_link_substitution_is_case_sensitive1()
{
// arrange
var templateLink = new Link("beerbyname", "/beers/{naMe}");
// act
var link = templateLink.CreateLink(new { nAme = "Sorry Charlie" });
// assert
Assert.Equal("/beers/", link.Href);
}
示例3: substitutes_templated_link
public void substitutes_templated_link()
{
// arrange
var templateLink = new Link("beerSearch", "/beers{?searchTerm}");
// act
var link = templateLink.CreateLink(new{searchTerm = "test"});
// assert
Assert.Equal("/beers?searchTerm=test", link.Href);
}
示例4: detects_nontemplated_link
public void detects_nontemplated_link()
{
// arrange
var templateLink = new Link("beerSearch", "/beers{?searchTerm}");
// act
var link = templateLink.CreateLink(new {});
// assert
Assert.False(link.IsTemplated);
}
示例5: detects_templated_link
public void detects_templated_link()
{
// arrange
var templateLink = new Link("beerSearch", "/beers?searchTerm={searchTerm}");
// act
var link = templateLink.CreateLink();
// assert
Assert.True(link.IsTemplated);
}
示例6: can_generate_link_without_templates
public void can_generate_link_without_templates()
{
// arrange
var templateLink = new Link("beers", "/beers");
// act
var link = templateLink.CreateLink(new{});
// assert
Assert.Equal("beers", link.Rel);
Assert.Equal(templateLink.Href, link.Href);
Assert.False(link.IsTemplated);
}
示例7: Create_Link
public void Create_Link(string href, string expectedHref, string title, string expectedTitle, bool? isTemplated, bool replaceParameters)
{
var parameters = new Dictionary<string, object> {
{ "one", 1 }
};
var link = new Link(
rel: "self",
title: title,
href: href,
replaceParameters: replaceParameters
);
var templatedLink = link.CreateLink(parameters);
Assert.Equal(expectedHref, templatedLink.Href);
Assert.Equal(expectedTitle, templatedLink.Title);
Assert.Equal(isTemplated, templatedLink.Templated);
}
示例8: create_link_substitution_is_case_sensitive2
public void create_link_substitution_is_case_sensitive2()
{
// arrange
var templateLink = new Link("beerbyname", "/beers/{nAme}");
// act
var link = templateLink.CreateLink(new { nAme = "This Works" });
// assert
Assert.Equal("/beers/This%20Works", link.Href);
}
示例9: create_link_uses_templates_title
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");
}