Ejemplo n.º 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, new FileServiceMock());

            // Assert
        }
Ejemplo n.º 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, new FileServiceMock());
            Routing.Register(routes);

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

            // Assert
            Assert.IsNotNull(routeData);
            Assert.That(routeData.RouteHandler, Is.Not.TypeOf <AttachmentRouteHandler>());
        }
Ejemplo n.º 3
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, new FileServiceMock());             // 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));
        }
Ejemplo n.º 4
0
        public void Attachments_With_SubApplication_Should_Have_Correct_Handler_And_Contain_Route_Values()
        {
            // Arrange
            ApplicationSettings settings = new ApplicationSettings();

            settings.AttachmentsRoutePath = "Attachments";
            string filename    = "somefile.png";
            string url         = string.Format("~/{0}/{1}", settings.AttachmentsRoutePath, filename);     // doesn't work without the ~
            var    mockContext = new StubHttpContextForRouting("/mywiki/", url);

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

            AttachmentRouteHandler.RegisterRoute(settings, routes, new FileServiceMock());

            // 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));
        }
Ejemplo n.º 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, new FileServiceMock()); // 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));
		}
Ejemplo n.º 6
0
		public void Attachments_With_SubApplication_Should_Have_Correct_Handler_And_Contain_Route_Values()
		{
			// Arrange
			ApplicationSettings settings = new ApplicationSettings();
			settings.AttachmentsRoutePath = "Attachments";
			string filename = "somefile.png";
			string url = string.Format("~/{0}/{1}", settings.AttachmentsRoutePath, filename); // doesn't work without the ~
			var mockContext = new StubHttpContextForRouting("/mywiki/", url);

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

			// 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));
		}
Ejemplo n.º 7
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, new FileServiceMock());

			// Assert
		}
Ejemplo n.º 8
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, new FileServiceMock());
			Routing.Register(routes);

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

			// Assert
			Assert.IsNotNull(routeData);
			Assert.That(routeData.RouteHandler, Is.Not.TypeOf<AttachmentRouteHandler>());
		}