Пример #1
0
        public void RedwoodRoute_BuildUrl_UrlTwoParameters()
        {
            var route = new RedwoodRoute("Article/id_{Id}/{Title}", null, null);

            var result = route.BuildUrl(new { Id = 15, Title = "Test" });

            Assert.AreEqual("Article/id_15/Test", result);
        }
Пример #2
0
        public void RedwoodRoute_IsMatch_UrlTwoParametersBothRequired_NoMatchWhenOneSpecified()
        {
            var route = new RedwoodRoute("Article/{Id}/{Title}", null, null);

            IDictionary<string, object> parameters;
            var result = route.IsMatch("Article/15", out parameters);

            Assert.IsFalse(result);
        }
Пример #3
0
        public void RedwoodRoute_IsMatch_UrlTwoParametersBothRequired_DifferentPart()
        {
            var route = new RedwoodRoute("Article/id_{Id}/{Title}", null, null);

            IDictionary<string, object> parameters;
            var result = route.IsMatch("Articles/id_15", out parameters);

            Assert.IsFalse(result);
        }
Пример #4
0
        public void RedwoodRoute_IsMatch_EmptyRouteMatchesEmptyUrl()
        {
            var route = new RedwoodRoute("", null, null);

            IDictionary<string, object> parameters;
            var result = route.IsMatch("", out parameters);

            Assert.IsTrue(result);
        }
Пример #5
0
        public void RedwoodRoute_IsMatch_UrlTwoParametersBothRequired_BothSpecified()
        {
            var route = new RedwoodRoute("Article/id_{Id}/{Title}", null, null);

            IDictionary<string, object> parameters;
            var result = route.IsMatch("Article/id_15/test", out parameters);

            Assert.IsTrue(result);
            Assert.AreEqual(2, parameters.Count);
            Assert.AreEqual("15", parameters["Id"]);
            Assert.AreEqual("test", parameters["Title"]);
        }
Пример #6
0
 public void RedwoodRoute_IsMatch_RouteMustNotStartWithSlash()
 {
     var route = new RedwoodRoute("/Test", null, null);
 }
Пример #7
0
 public void RedwoodRoute_IsMatch_RouteMustNotEndWithSlash()
 {
     var route = new RedwoodRoute("Test/", null, null);
 }
Пример #8
0
        public void RedwoodRoute_IsMatch_UrlWithoutParametersNoMatch()
        {
            var route = new RedwoodRoute("Hello/Test/Page.txt", null, null);

            IDictionary<string, object> parameters;
            var result = route.IsMatch("Hello/Test/Page", out parameters);

            Assert.IsFalse(result);
        }
Пример #9
0
        public void RedwoodRoute_IsMatch_UrlTwoParametersOneSpecifiedOneDefault()
        {
            var route = new RedwoodRoute("Article/{Id}/{Title}", new { Title = "test" }, null);

            IDictionary<string, object> parameters;
            var result = route.IsMatch("Article/15", out parameters);

            Assert.IsTrue(result);
            Assert.AreEqual(2, parameters.Count);
            Assert.AreEqual("15", parameters["Id"]);
            Assert.AreEqual("test", parameters["Title"]);
        }