コード例 #1
0
        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());
        }
コード例 #2
0
        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());
        }
コード例 #3
0
ファイル: Global.asax.cs プロジェクト: ChrisPelatari/SubText
        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());
        }