public void ContainsKeyShouldThrowArgumentExceptionWhenKeyIs(string key) { Func <bool> func = () => sut.ContainsKey(key); var exception = func.Should().Throw <ArgumentException>().Which; exception.Message.Should().Be("Parameter 'key' must not be null or empty."); exception.ParamName.Should().BeNull(); }
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 Link GetLink(LinkRequest request) { if (request == null) { throw new ArgumentNullException(nameof(request)); } if (!request.ContainsKey(LinkRequestBuilder.RouteNameKey)) { throw new ArgumentException($"Parameter '{nameof(request)}' must contain a '{LinkRequestBuilder.RouteNameKey}' value."); } if (string.IsNullOrWhiteSpace(request.GetRouteName())) { throw new ArgumentException($"The '{LinkRequestBuilder.RouteNameKey}' item in the '{nameof(request)}' parameter must not be null or empty."); } return(DoGetLink(request)); }