Example #1
0
        public void GetRouteData_ShouldNotReturnData_WhenNameIsOfInvalidController()
        {
            var handler = new ApiRoute("test", null, Assembly.GetAssembly(typeof(ApiRouteTests)));

            var context = new MockHttpContext
            {
                Request = new MockHttpRequest
                {
                    RawUrl = "/test/bad"
                }
            };

            Assert.IsNull(handler.GetRouteData(context));
        }
Example #2
0
        public void GetRouteData_ShouldReturnDataWithController_WhenNameIsOfValidController()
        {
            var handler = new ApiRoute("test", null, Assembly.GetAssembly(typeof(ApiRouteTests)));

            var context = new MockHttpContext
            {
                Request = new MockHttpRequest
                {
                    RawUrl = "/test/valid"
                }
            };

            var type = typeof(ValidController);

            Assert.AreEqual(type.FullName, handler.GetRouteData(context).Controller.GetType().FullName);
        }
Example #3
0
 public void Ctor_ShouldSetPrefix()
 {
     var handler = new ApiRoute("/test/", null, Assembly.GetAssembly(typeof(ApiRouteTests)));
     Assert.AreEqual("/test/", handler.UrlPrefix);
 }
Example #4
0
 public void Ctor_ShouldAppendAndPrependSlashToPrefix()
 {
     var handler = new ApiRoute("test", null, Assembly.GetAssembly(typeof(ApiRouteTests)));
     Assert.AreEqual("/test/", handler.UrlPrefix);
 }