public void CreateController_WithControllerName_CanCreateControllerCaseInsensitively() { // arrange var serviceLocator = new Mock<IDependencyResolver>(); serviceLocator.Setup(l => l.GetService(typeof(IdenticonController))).Returns(new IdenticonController()); var factory = new SubtextControllerFactory(serviceLocator.Object); // act var controller = factory.CreateController(null, "identicon"); // assert Assert.AreEqual(typeof(IdenticonController), controller.GetType()); }
public void ReleaseController_WithDisposableController_CallsDisposeOnController() { // arrange var serviceLocator = new Mock<IDependencyResolver>(); var factory = new SubtextControllerFactory(serviceLocator.Object); var controller = new Mock<IController>(); var disposable = controller.As<IDisposable>(); disposable.Setup(d => d.Dispose()); // act factory.ReleaseController(controller.Object); // assert disposable.Verify(d => d.Dispose()); }
public virtual void StartApplication(SubtextRouteMapper routes, HttpServerUtilityBase server) { Routes.RegisterRoutes(routes); var factory = new SubtextControllerFactory(routes.ServiceLocator); ControllerBuilder.Current.SetControllerFactory(factory); var deprecatedPaths = new[] { "~/Admin", "~/HostAdmin", "~/Install", "~/SystemMessages", "~/AggDefault.aspx", "~/DTP.aspx", "~/ForgotPassword.aspx", "~/login.aspx", "~/logout.aspx", "~/MainFeed.aspx" }; var invalidPaths = from path in deprecatedPaths where Directory.Exists(server.MapPath(path)) || File.Exists(server.MapPath(path)) select path; DeprecatedPhysicalPaths = new ReadOnlyCollection<string>(invalidPaths.ToList()); }