コード例 #1
0
        public static string GetRouteName(this LinkRequest request)
        {
            if (request == null)
            {
                throw new ArgumentNullException(nameof(request));
            }

            return(request.GetValueOrDefault <string>(LinkRequestBuilder.RouteNameKey));
        }
コード例 #2
0
        public static object GetRouteValues(this LinkRequest request)
        {
            if (request == null)
            {
                throw new ArgumentNullException(nameof(request));
            }

            return(request.GetValueOrDefault(LinkRequestBuilder.RouteValuesKey));
        }
コード例 #3
0
        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);
        }
コード例 #4
0
        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();
        }