Ejemplo n.º 1
0
 public PublishingDisablerTests()
 {
     _eventContext =
         new TestableEventContext(
             new EventContext(new List <IEvent> {
         new TestEventImplementation(), new TestEventImplementation2()
     }));
     TestEventImplementation.Reset();
     TestEventImplementation2.Reset();
     _eventContext.FakeNonCoreEvents = false;
 }
Ejemplo n.º 2
0
        protected InMemoryDatabaseTest()
        {
            if (Configuration == null)
            {
                lock (lockObject)
                {
                    var assemblies = new List<Assembly> { typeof(InMemoryDatabaseTest).Assembly };
                    var nHibernateModule = new NHibernateConfigurator(new SqliteInMemoryProvider())
                    {
                        CacheEnabled = true,
                        ManuallyAddedAssemblies = assemblies
                    };
                    Configuration = nHibernateModule.GetConfiguration();

                    SessionFactory = Configuration.BuildSessionFactory();
                }
            }
            Session = SessionFactory.OpenFilteredSession(Kernel.Get<HttpContextBase>());
            Kernel.Bind<ISession>().ToMethod(context => Session);
            Kernel.Bind<IStatelessSession>().ToMethod(context => SessionFactory.OpenStatelessSession());

            new SchemaExport(Configuration).Execute(false, true, false, Session.Connection, null);

            SetupUser();


            CurrentSite = Session.Transact(session =>
            {
                var site = new Site { Name = "Current Site", BaseUrl = "www.currentsite.com", Id = 1 };
                CurrentRequestData.CurrentSite = site;
                session.Save(site);
                return site;
            });

            CurrentRequestData.SiteSettings = new SiteSettings { TimeZone = TimeZoneInfo.Local.Id };

            CurrentRequestData.ErrorSignal = new ErrorSignal();

            Kernel.Unbind<IEventContext>();
            Kernel.Load(new ServiceModule());
            Kernel.Load(new SettingsModule(true));
            Kernel.Load(new FileSystemModule());
            Kernel.Load(new SiteModule());
            Kernel.Load(new GenericBindingsModule());
            _eventContext = new TestableEventContext(Kernel.Get<EventContext>());
            Kernel.Rebind<IEventContext>().ToMethod(context => EventContext);

        }