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);
        }
        private IWebApplicationHost CreateHost()
        {
            var registration = new Mock<IWebModulesRegistration>();
            var migrationRunner = new Mock<IMigrationRunner>();

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

            return host;
        }