コード例 #1
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(Session.Connection));

            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.Rebind <IExternalUserSource>().ToConstant(A.Fake <IExternalUserSource>());
            _eventContext = new TestableEventContext(Kernel.Get <EventContext>());
            Kernel.Rebind <IEventContext>().ToMethod(context => EventContext);
        }
コード例 #2
0
            public TestableEventContextDisabler(IDisposable coreContextDisable,
                                                TestableEventContext testableEventContext, params Type[] types)
            {
                _coreContextDisable   = coreContextDisable;
                _testableEventContext = testableEventContext;

                foreach (Type type in types)
                {
                    if (_testableEventContext.DisabledTypes.Add(type))
                    {
                        _typesToDisable.Add(type);
                    }
                }
            }