public void Should_be_able_to_Generate_Url_From_the_Routes() { HttpRequestMessage request = new HttpRequestMessage(); request.RequestUri = new Uri("http://localhost/api/home"); HttpConfiguration configuration = new HttpConfiguration(); request.Properties[HttpPropertyKeys.HttpConfigurationKey] = configuration; request.AddDefaultRoute(); IProvideHyperLink provideHyperLink = new HyperLinkProvider(request); Uri url = provideHyperLink.GetRelativeUri<HomeController>(p => p.Get()); url.ToString().Should().Be("/api/home"); }
public void Should_throw_an_exception_if_the_expression_is_not_a_Method() { HttpRequestMessage request = new HttpRequestMessage(); request.RequestUri = new Uri("http://localhost/api/home"); HttpConfiguration configuration = new HttpConfiguration(); request.Properties[HttpPropertyKeys.HttpConfigurationKey] = configuration; request.AddDefaultRoute(); IProvideHyperLink provideHyperLink = new HyperLinkProvider(request); Expression<Action<object>> expressionWhichIsNotAMethodCall = _ => new object(); Uri url = provideHyperLink.GetRelativeUri(expressionWhichIsNotAMethodCall); }