示例#1
0
        public void AttachmentsRoute_Using_Files_Route_Should_Throw_Exception()
        {
            // Arrange
            ApplicationSettings settings = new ApplicationSettings();
            settings.AttachmentsRoutePath = "Files";
            string filename = "somefile.png";
            string url = string.Format("~/{0}/{1}", settings.AttachmentsRoutePath, filename);
            var mockContext = new StubHttpContextForRouting("", url);

            RouteTable.Routes.Clear();
            RouteCollection routes = new RouteCollection();

            // Act
            Routing.Register(RouteTable.Routes);
            AttachmentRouteHandler.RegisterRoute(settings, routes);

            // Assert
        }
示例#2
0
        public void Attachments_In_Standard_Controller_Path_Should_Not_Map_To_Attachments_Handler()
        {
            // Arrange
            ApplicationSettings settings = new ApplicationSettings();
            string url = "/pages/6/attachments-are-us";
            var mockContext = new StubHttpContextForRouting("", url);

            RouteTable.Routes.Clear();
            RouteCollection routes = new RouteCollection();
            AttachmentRouteHandler.RegisterRoute(settings, routes);
            Routing.Register(routes);

            // Act
            RouteData routeData = routes.GetRouteData(mockContext);

            // Assert
            Assert.IsNotNull(routeData);
            Assert.That(routeData.RouteHandler, Is.Not.TypeOf<AttachmentRouteHandler>());
        }
示例#3
0
        public void AttachmentsRoute_Using_Files_Route_Should_Throw_Exception()
        {
            // Arrange
            ApplicationSettings settings = new ApplicationSettings();

            settings.AttachmentsRoutePath = "Files";
            string filename    = "somefile.png";
            string url         = string.Format("~/{0}/{1}", settings.AttachmentsRoutePath, filename);
            var    mockContext = new StubHttpContextForRouting("", url);

            RouteTable.Routes.Clear();
            RouteCollection routes = new RouteCollection();

            // Act
            Routing.Register(RouteTable.Routes);
            AttachmentRouteHandler.RegisterRoute(settings, routes);

            // Assert
        }
示例#4
0
        public void Attachments_In_Standard_Controller_Path_Should_Not_Map_To_Attachments_Handler()
        {
            // Arrange
            ApplicationSettings settings = new ApplicationSettings();
            string url         = "/pages/6/attachments-are-us";
            var    mockContext = new StubHttpContextForRouting("", url);

            RouteTable.Routes.Clear();
            RouteCollection routes = new RouteCollection();

            AttachmentRouteHandler.RegisterRoute(settings, routes);
            Routing.Register(routes);

            // Act
            RouteData routeData = routes.GetRouteData(mockContext);

            // Assert
            Assert.IsNotNull(routeData);
            Assert.That(routeData.RouteHandler, Is.Not.TypeOf <AttachmentRouteHandler>());
        }
示例#5
0
        public void Attachments_Should_Have_Correct_Handler_And_Contain_Route_Values()
        {
            // Arrange
            ApplicationSettings settings = new ApplicationSettings();
            string filename = "somefile.png";
            string url = string.Format("~/{0}/{1}", settings.AttachmentsRoutePath, filename);
            var mockContext = new StubHttpContextForRouting("", url);

            RouteTable.Routes.Clear();
            RouteCollection routes = new RouteCollection();
            AttachmentRouteHandler.RegisterRoute(settings, routes); // has to be registered first
            Routing.Register(routes);

            // Act
            RouteData routeData = routes.GetRouteData(mockContext);

            // Assert
            Assert.IsNotNull(routeData);
            Assert.That(routeData.RouteHandler, Is.TypeOf<AttachmentRouteHandler>());
            Assert.That(routeData.Values["filename"].ToString(), Is.EqualTo(filename));
        }
示例#6
0
        public void Attachments_Should_Have_Correct_Handler_And_Contain_Route_Values()
        {
            // Arrange
            ApplicationSettings settings = new ApplicationSettings();
            string filename    = "somefile.png";
            string url         = string.Format("~/{0}/{1}", settings.AttachmentsRoutePath, filename);
            var    mockContext = new StubHttpContextForRouting("", url);

            RouteTable.Routes.Clear();
            RouteCollection routes = new RouteCollection();

            AttachmentRouteHandler.RegisterRoute(settings, routes);             // has to be registered first
            Routing.Register(routes);

            // Act
            RouteData routeData = routes.GetRouteData(mockContext);

            // Assert
            Assert.IsNotNull(routeData);
            Assert.That(routeData.RouteHandler, Is.TypeOf <AttachmentRouteHandler>());
            Assert.That(routeData.Values["filename"].ToString(), Is.EqualTo(filename));
        }