コード例 #1
0
        public void Should_Not_Find_Is_Module_Registered_By_AreaName()
        {
            var service = new DefaultWebModulesRegistration(new Mock<IAssemblyLoader>().Object, new Mock<IControllerExtensions>().Object);
            var isRegisteted = service.IsModuleRegisteredByAreaName("Test");

            Assert.IsFalse(isRegisteted);
        }
コード例 #2
0
        public void Should_Not_Find_Module_By_AreaName()
        {
            var service = new DefaultWebModulesRegistration(new Mock<IAssemblyLoader>().Object, new Mock<IControllerExtensions>().Object);
            var descriptor = service.FindModuleByAreaName("Test");

            Assert.IsNull(descriptor);
        }
コード例 #3
0
        public void Should_Find_Is_Module_Registered_By_AreaName()
        {
            var loader = new Mock<IAssemblyLoader>();
            loader
                .Setup(l => l.GetLoadableTypes(It.IsAny<Assembly>()))
                .Returns<Assembly>(r => new[] { typeof(SampleWebModuleDescriptor) });

            var service = new DefaultWebModulesRegistration(loader.Object, new Mock<IControllerExtensions>().Object);
            service.AddModuleDescriptorTypeFromAssembly(GetType().Assembly);
            service.InitializeModules();

            var sampleDescriptor = new SampleWebModuleDescriptor();

            var isRegisteted = service.IsModuleRegisteredByAreaName(sampleDescriptor.AreaName);
            Assert.IsTrue(isRegisteted);
        }
コード例 #4
0
        public void Should_Register_Route_Correctly()
        {
            var loader = new Mock<IAssemblyLoader>();
            loader
                .Setup(l => l.GetLoadableTypes(It.IsAny<Assembly>()))
                .Returns<Assembly>(r => new[] { typeof(SampleWebModuleDescriptor) });

            var service = new DefaultWebModulesRegistration(loader.Object, new Mock<IControllerExtensions>().Object);
            service.AddModuleDescriptorTypeFromAssembly(GetType().Assembly);
            service.InitializeModules();

            var routes = new RouteCollection();
            service.RegisterKnownModuleRoutes(routes);

            Assert.IsNotEmpty(routes);
            Assert.IsTrue(routes.Any(r => ((Route)r).Url == "module-bettermoduleswebsample/{controller}/{action}"));
        }