CMajor.Tests.RouteTestHelper.AssertRoute C# (CSharp) Method

AssertRoute() public static method

public static AssertRoute ( RouteCollection routes, string url, object expectations, string httpMethod = "GET", string formMethod = null ) : void
routes RouteCollection
url string
expectations object
httpMethod string
formMethod string
return void
        public static void AssertRoute(RouteCollection routes, string url, object expectations, string httpMethod = "GET", string formMethod = null)
        {
            var httpContext = CreateHttpContext(url, httpMethod, formMethod);

            RouteData routeData = routes.GetRouteData(httpContext);

            Assert.True(routeData != null, "There is not matched route for provided url: " + url);

            foreach (PropertyValue property in GetProperties(expectations)) {
                var expected = string.Equals(property.Value.ToString(), routeData.Values[property.Name].ToString(), StringComparison.OrdinalIgnoreCase);
                var msg = string.Format("Expected '{0}', not '{1}' for '{2}'.", property.Value, routeData.Values[property.Name], property.Name);

                Assert.True(expected, msg);
            }
        }