コード例 #1
0
        internal static string?GetRouteName(this HttpRouteCollection routes, IHttpRoute route)
        {
            foreach (var item in routes.ToDictionary())
            {
                if (Equals(item.Value, route))
                {
                    return(item.Key);
                }
            }

            return(default);
コード例 #2
0
        internal static string GetRouteName(this HttpRouteCollection routes, IHttpRoute route)
        {
            Contract.Requires(routes != null);
            Contract.Requires(route != null);

            foreach (var item in routes.ToDictionary())
            {
                if (Equals(item.Value, route))
                {
                    return(item.Key);
                }
            }

            return(null);
        }
        public void to_dictionary_should_convert_route_collection()
        {
            // arrange
            var route  = Mock.Of <IHttpRoute>();
            var routes = new HttpRouteCollection()
            {
                { "test", route },
            };

            // act
            var dictionary = routes.ToDictionary();

            // assert
            dictionary.Should().BeEquivalentTo(new Dictionary <string, IHttpRoute>()
            {
                ["test"] = route
            });
        }