示例#1
0
        public static void AssemblyInit(TestContext context)
        {
            _application = new TestUmbracoApplication();
            _application.Start();

            //Because the ApplicationEventHandler isn't recognized from the Test application call the CreateTables method manually
            Startup.EasyADApplication.CreateTables(ApplicationContext.Current);
        }
示例#2
0
        protected virtual void BeforeEachTest()
        {
            _application = new TestUmbracoApplication();
            _application.Start();

            MigrationRecords       = new DatabaseMigrationRecordRepository(_application.ApplicationContext.DatabaseContext.Database);
            MigrationConfiguration = new MigrationConfiguration();
            _migrator = CreateMigrator();
        }
示例#3
0
 protected virtual void AfterEachTest()
 {
     if (_application != null)
     {
         _application.Stop();
         ((IDisposable)_application.ApplicationContext)?.Dispose();
     }
     _application = null;
     _migrator    = null;
 }
示例#4
0
        public static void AssemblyInit(TestContext context)
        {
            _application = new TestUmbracoApplication();
            _application.Start();

            //Because the ApplicationEventHandler isn't recognized from the Test application call the CreateTables method manually
            Startup.ApplicationEvents.CreateTables(ApplicationContext.Current);

            //Configure the GroupBasedUserManager to use the TestGroupBasedUserManager instead of the real ActiveDirectory
            Managers.ManagerFactory.SetManager <TestGroupBasedUserManager>();

            //Add the GroupBasedUserManager to the TestContext
            var manager = Managers.ManagerFactory.GetManager();

            context.Properties.Add(ManagerPropertyKey, manager);
        }
示例#5
0
        public void ComponentLifeCycle()
        {
            using (var app = new TestUmbracoApplication())
            {
                app.HandleApplicationStart(app, new EventArgs());

                var e = app.Runtime.State.BootFailedException;
                var m = "";
                switch (e)
                {
                case null:
                    m = "";
                    break;

                case BootFailedException bfe when bfe.InnerException != null:
                    m = "BootFailed: " + bfe.InnerException.GetType() + " " + bfe.InnerException.Message + " " + bfe.InnerException.StackTrace;
                    break;

                default:
                    m = e.GetType() + " " + e.Message + " " + e.StackTrace;
                    break;
                }

                Assert.AreNotEqual(RuntimeLevel.BootFailed, app.Runtime.State.Level, m);
                Assert.IsTrue(TestComposer.Ctored);
                Assert.IsTrue(TestComposer.Composed);
                Assert.IsTrue(TestComponent.Ctored);
                Assert.IsNotNull(TestComponent.ProfilingLogger);
                Assert.IsInstanceOf <ProfilingLogger>(TestComponent.ProfilingLogger);
                Assert.IsInstanceOf <DebugDiagnosticsLogger>(((ProfilingLogger)TestComponent.ProfilingLogger).Logger);

                // note: components are NOT disposed after boot

                Assert.IsFalse(TestComponent.Terminated);

                app.HandleApplicationEnd();
                Assert.IsTrue(TestComponent.Terminated);
            }
        }