Esempio n. 1
0
        public void Throwing_IsIntercepted_InMediumTrust()
        {
            IEngine engine = new ContentEngine(new MediumTrustServiceContainer(), new EventBroker(), new ContainerConfigurer());

            engine.Initialize();

            var schemaCreator = new SchemaExport(engine.Resolve <IConfigurationBuilder>().BuildConfiguration());
            var conn          = engine.Resolve <ISessionProvider>().OpenSession.Session.Connection;

            schemaCreator.Execute(false, true, false, conn, null);

            engine.SecurityManager.Enabled = false;

            ContentItem root = new ThrowableItem();

            root.Name = "root_mediumtrust";

            ContentItem item = new ThrowableItem();

            item.Name = "bin's destiny";
            item.AddTo(root);

            engine.Persister.Save(root);
            engine.Resolve <IHost>().DefaultSite.RootItemID  = root.ID;
            engine.Resolve <IHost>().DefaultSite.StartPageID = root.ID;

            engine.Persister.Delete(item);

            Assert.That(root.Children.Count, Is.EqualTo(1));
            Assert.That(root.Children[0], Is.TypeOf(typeof(TrashContainerItem)));
            Assert.That(root.Children[0].Children[0], Is.EqualTo(item));
        }
Esempio n. 2
0
        public void Trash_IsNotPurged_Before_PurgeInterval_HasElapsed(TrashPurgeInterval interval)
        {
            trash.PurgeInterval = interval;
            engine.Persister.Save(trash);

            ContentItem item = new ThrowableItem();
            item.Name = "nullness' avenge";
            item.AddTo(root);
            engine.Persister.Save(item);
            engine.Persister.Delete(item);

            Utility.CurrentTime = () => N2.Utility.CurrentTime().AddDays((int)interval).AddSeconds(-10);

            engine.Resolve<ITrashHandler>().PurgeOldItems();

            Assert.That(trash.Children.Count, Is.EqualTo(1));
        }
Esempio n. 3
0
        public void Trash_CanBePurged_OfOldItems(TrashPurgeInterval interval)
        {
            trash.PurgeInterval = interval;
            engine.Persister.Save(trash);

            ContentItem item = new ThrowableItem();
            item.Name = "nullness' destiny";
            item.AddTo(root);
            engine.Persister.Save(item);
            engine.Persister.Delete(item);

            Utility.CurrentTime = () => DateTime.Now.AddDays((int)interval);

            engine.Resolve<ITrashHandler>().PurgeOldItems();

            Assert.That(trash.Children.Count, Is.EqualTo(0));
        }
Esempio n. 4
0
        public void Trash_IsNotPurged_WhenInterval_IsSetToNever()
        {
            trash.PurgeInterval = TrashPurgeInterval.Never;
            engine.Persister.Save(trash);

            ContentItem item = new ThrowableItem();

            item.Name = "nullness' neverland";
            item.AddTo(root);
            engine.Persister.Save(item);
            engine.Persister.Delete(item);

            Utility.CurrentTime = () => DateTime.Now.AddDays(1000);

            engine.Resolve <ITrashHandler>().PurgeOldItems();

            Assert.That(trash.Children.Count, Is.EqualTo(1));
        }
Esempio n. 5
0
        public void Trash_IsNotPurged_Before_PurgeInterval_HasElapsed(TrashPurgeInterval interval)
        {
            trash.PurgeInterval = interval;
            engine.Persister.Save(trash);

            ContentItem item = new ThrowableItem();

            item.Name = "nullness' avenge";
            item.AddTo(root);
            engine.Persister.Save(item);
            engine.Persister.Delete(item);

            Utility.CurrentTime = () => N2.Utility.CurrentTime().AddDays((int)interval).AddSeconds(-10);

            engine.Resolve <ITrashHandler>().PurgeOldItems();

            Assert.That(trash.Children.Count, Is.EqualTo(1));
        }
Esempio n. 6
0
        public void Trash_CanBePurged_OfOldItems(TrashPurgeInterval interval)
        {
            trash.PurgeInterval = interval;
            engine.Persister.Save(trash);

            ContentItem item = new ThrowableItem();

            item.Name = "nullness' destiny";
            item.AddTo(root);
            engine.Persister.Save(item);
            engine.Persister.Delete(item);

            Utility.CurrentTime = () => N2.Utility.CurrentTime().AddDays((int)interval);

            engine.Resolve <ITrashHandler>().PurgeOldItems();

            Assert.That(trash.Children.Count, Is.EqualTo(0));
        }
Esempio n. 7
0
        public void Throwing_IsIntercepted_InMediumTrust()
        {
            IEngine engine = new ContentEngine(new MediumTrustServiceContainer(), new EventBroker(), new ContainerConfigurer());
            engine.Initialize();
            engine.Persister.Dispose();

            var schemaCreator = new SchemaExport(engine.Resolve<IConfigurationBuilder>().BuildConfiguration());
            var conn = engine.Resolve<ISessionProvider>().OpenSession.Session.Connection;
            schemaCreator.Execute(false, true, false, conn, null);

            engine.SecurityManager.Enabled = false;

            ContentItem root = new ThrowableItem();
            root.Name = "root_mediumtrust";

            ContentItem item = new ThrowableItem();
            item.Name = "bin's destiny";
            item.AddTo(root);

            engine.Persister.Save(root);
            engine.Resolve<IHost>().DefaultSite.RootItemID = root.ID;
            engine.Resolve<IHost>().DefaultSite.StartPageID = root.ID;

            engine.Persister.Delete(item);

            Assert.That(root.Children.Count, Is.EqualTo(1));
            Assert.That(root.Children[0], Is.TypeOf(typeof(TrashContainerItem)));
            Assert.That(root.Children[0].Children[0], Is.EqualTo(item));
        }
        public void Trash_IsNotPurged_WhenInterval_IsSetToNever()
        {
            trash.PurgeInterval = TrashPurgeInterval.Never;
            engine.Persister.Save(trash);

            ContentItem item = new ThrowableItem();
            item.Name = "nullness' neverland";
            item.AddTo(root);
            engine.Persister.Save(item);
            engine.Persister.Delete(item);

            Utility.CurrentTime = () => DateTime.Now.AddDays(1000);

            engine.Resolve<ITrashHandler>().PurgeOldItems();

            Assert.That(trash.Children.Count, Is.EqualTo(1));
        }