public static string GetRouteName(this LinkRequest request) { if (request == null) { throw new ArgumentNullException(nameof(request)); } return(request.GetValueOrDefault <string>(LinkRequestBuilder.RouteNameKey)); }
public static object GetRouteValues(this LinkRequest request) { if (request == null) { throw new ArgumentNullException(nameof(request)); } return(request.GetValueOrDefault(LinkRequestBuilder.RouteValuesKey)); }
public static bool IsTemplated(this LinkRequest request) { if (request == null) { throw new ArgumentNullException(nameof(request)); } return(request.ContainsKey(IsTemplatedEnricher.TemplatedKey) && request.GetValueOrDefault(IsTemplatedEnricher.TemplatedKey) is bool templated && templated); }
public void GetValueOrDefaultShouldThrowArgumentExceptionWhenKeyIs(string key) { Func <object> func = () => sut.GetValueOrDefault(key); var exception = func.Should().Throw <ArgumentException>().Which; exception.Message.Should().Be("Parameter 'key' must not be null or empty."); exception.ParamName.Should().BeNull(); }