public void Should_Initialize_Context_Correctly()
        {
            var descriptor = new SampleModuleDescriptor();
            var context = new ModuleRegistrationContext(descriptor);

            Assert.AreEqual(context.ModuleDescriptor, descriptor);
            Assert.IsNotNull(context.GetRegistrationName());
        }
        /// <summary>
        /// Registers the types.
        /// </summary>
        /// <param name="registrationContext">The registration context.</param>
        /// <param name="containerBuilder">The container builder.</param>
        protected override void RegisterModuleDescriptor(ModuleRegistrationContext registrationContext, ContainerBuilder containerBuilder)
        {
            var webContext = registrationContext as WebModuleRegistrationContext;
            if (webContext != null)
            {
                var webDescriptor = (WebModuleDescriptor)webContext.ModuleDescriptor;
                webDescriptor.RegisterModuleCommands(webContext, containerBuilder);
                webDescriptor.RegisterModuleControllers(webContext, containerBuilder, controllerExtensions);
                webDescriptor.RegisterCustomRoutes(webContext, containerBuilder);
            }

            base.RegisterModuleDescriptor(registrationContext, containerBuilder);
        }
        public void ShouldExecute_OnApplicationStart_Correctly()
        {
            eventFired = false;
            var routesRegistered = false;
            var databaseMigrated = false;

            var registration = new Mock<IWebModulesRegistration>();
            registration
                .Setup(r => r.RegisterKnownModuleRoutes(It.IsAny<RouteCollection>()))
                .Callback<RouteCollection>(rc => routesRegistered = true);

            var moduleDescriptor1 = new ModuleRegistrationContext(new Mock<ModuleDescriptor>().Object);
            var moduleDescriptor2 = new ModuleRegistrationContext(new Mock<ModuleDescriptor>().Object);

            registration
                .Setup(r => r.GetModules())
                .Returns(() => new[] { moduleDescriptor1, moduleDescriptor2 });

            var migrationRunner = new Mock<IMigrationRunner>();
            migrationRunner
                .Setup(r => r.MigrateStructure(It.IsAny<IList<ModuleDescriptor>>()))
                .Callback<IList<ModuleDescriptor>>(
                    descriptors =>
                    {
                        Assert.AreEqual(descriptors.Count, 2);
                        Assert.IsTrue(descriptors.Any(d => d == moduleDescriptor1.ModuleDescriptor));
                        Assert.IsTrue(descriptors.Any(d => d == moduleDescriptor2.ModuleDescriptor));

                        databaseMigrated = true;
                    });

            var host = new DefaultWebApplicationHost(registration.Object, migrationRunner.Object);
            CreateApplication();

            WebCoreEvents.Instance.HostStart += Instance_Fired;
            host.OnApplicationStart(application);
            WebCoreEvents.Instance.HostStart -= Instance_Fired;

            Assert.IsTrue(eventFired);
            Assert.IsTrue(routesRegistered);
            Assert.IsTrue(databaseMigrated);
        }
 /// <summary>
 /// Registers module types.
 /// </summary>
 /// <param name="context">The area registration context.</param>
 /// <param name="containerBuilder">The container builder.</param>
 public virtual void RegisterModuleTypes(ModuleRegistrationContext context, ContainerBuilder containerBuilder)
 {
 }
示例#5
0
 /// <summary>
 /// Registers the types.
 /// </summary>
 /// <param name="registrationContext">The registration context.</param>
 /// <param name="containerBuilder">The container builder.</param>
 protected virtual void RegisterModuleDescriptor(ModuleRegistrationContext registrationContext, ContainerBuilder containerBuilder)
 {
     registrationContext.ModuleDescriptor.RegisterModuleTypes(registrationContext, containerBuilder);
 }
 /// <summary>
 /// Registers the types.
 /// </summary>
 /// <param name="registrationContext">The registration context.</param>
 /// <param name="containerBuilder">The container builder.</param>
 protected virtual void RegisterModuleDescriptor(ModuleRegistrationContext registrationContext, ContainerBuilder containerBuilder)
 {
     registrationContext.ModuleDescriptor.RegisterModuleTypes(registrationContext, containerBuilder);
 }