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);
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 }); }